Example I/O and interrupt problems

1. List the tasks performed by an interrupt service routine which is called when the computer user presses a keyboard key.

an answer


2. A series of interrupts of different hardware priority levels occurs in the following time sequence, with times in seconds:

timeinterrupt
1IRQ1
3IRQ3
6IRQ4
9IRQ2

Higher numbers indicate more immediate priority (i.e. aside from zero, one is the lowest priority). Assume that each interrupt takes four seconds of CPU time to process. Complete the following chart indicating at which priority level the CPU will be running during the indicated second.

timepriority
00
11
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 

answer


3. What would happen if you enabled an I/O interrupt (such as interrupts on keyboard keypresses) but did not initialize its interrupt vector?

answer


4. On the PDP-11, we have memory-mapped i/o locations for one byte of terminal input and one byte of output, and status bytes for each. They can be defined as:

KBSTATUS = 177560
TTYIN = 177562
PRSTATUS = 177564
TTYOUT = 177566

TTYIN and TTYOUT are 8-bit i/o registers through which a single ASCII character code is transferred. When the user presses a key, its ASCII code goes into the TTYIN register. At this point, the most-significant-bit of the 8-bit KBSTATUS register is set to 1. When you MOV the byte out of TTYIN, that most-significant-bit goes to 0. Until the next keypress.

For output, you write the ascii character code into TTYOUT. At this point, PRSTATUS's high bit goes to 0. Eventually the character gets printed. As soon as the hardware is ready for another character code (which is _during_ the printing, so that you can keep it going continuously; that is, it lets us know as soon as it no longer needs TTYOUT's contents to be stable with the old value), PRSTATUS's high bit goes to 1.

a) Write code to read and echo a line, ended by carriage return (octal 15), into bytes beginning at LOC. Ignore buffer overrun problems (i.e. the situation where the user types more characters than there is space for at LOC).

answer

b) Write an interrupt-oriented version of the above.

answer


[CSC 258 additional problems] [main course page]