Fall 2000 |
Project 5: I/O in MIPSPolling and Interrupt Driven |
CS61C Dave Patterson |
Project Overview:
Project Assignment:
Complete the following mission objectives.
Mission Objective
#2: Output with polling
print.s contains an incorrect
version of a character output handler corresponding to C's putchar function.
The problem is that it fails to check that the terminal is ready to accept
a character before it sends the character to the terminal.
Run the program and observe
its behavior when attempting to print the given string; then try it with
a longer string. Fix the code by inserting, immediately prior to storing
into the terminal data register, a short loop that exists only when the
terminal "ready bit" is on (this is not difficult, just a few lines of
code will do it).
Mission Object #3:
Interrupt driven output
For the second part of
the project you will modify the file o.s. This file contains a function
print
which places a string into a ring buffer one character at a time, and an
interrupt handler. The print function is already created for you. It puts
each character into the ring buffer and then ensures that interrupts are
enabled for the terminal output device. If the ring buffer is full, it
simply waits until the ring buffer has enough space.
Your interrupt handler should complete the process of outputting characters. When an interrupt is received, it should do the following: if a character is waiting to be outputted and the terminal is ready to print out the character, that character should be printed and the ring buffer advanced to the next character. If a character is waiting and the terminal is not ready (a possibility if some other interrupt is received which you don't currently handle), your interrupt handler should simply return. And if there are no character waiting to be outputted, interrupts should be disabled for the character output device, to prevent the output device from sending further interrupts.
Once it is completed, your program should continue to print the sentence on the monitor (stop it with an interrupt signal CTRL+C).
More information on
Ringer Buffers and an example interrupt code: Ring
Buffers and Example Code
Mission Objective
#4: Interrupt driven Input/Output
Now that you have a working
output routine in o.s, you should copy your code into io.s and proceed
to modify it along the following lines. You should change it so that it
handles input as well as output. You will need to write a function called
getchar which reads characters from a different ring buffer, and waits
if the buffer is empty for a character to become available. You should
also modify your interrupt handler so that if there is a character waiting
on the input and space in the new ring buffer, the character is read in
and inserted into the new ring buffer. Otherwise, the character should
be discarded.
Submit Project:
Final Remarks: