CS 61C Homework 7-1
Background reading
P&H Sections 7.4-7.7, A.8, p673 677, Chapter 8
Administrative requirements
Submit your solution online by 8 pm on the 8th of August, 2004.
Do this by creating a directory named hw7-1 that contains the file out.s for
problem 1 and hw7-1.txt for the rest of the problems.
(put your answers to the problems in here). From within the directory, type:
submit hw7-1
This is not a partnership assignment -- hand in your work, and
don't collaborate with anyone else.
Problem 1: Interrupts
The first part of the code in ~cs61c/lib/out.fw.s contains a __start routine that repeatedly prints a string of text, along with a print function that transfer characters from its argument string to the output buffer. When there is space in the output buffer, all is well. If there is no space, the routine simply waits until space appears. This works because an interrupt will occur when the terminal's ready bit goes on and the interrupt service routine will clear some space in the buffer. You will add the interrupt service routine to this code. Programming interrupt service routines is more challenging then programming typical user programs, mainly because the code is not executed in sequence - it is executed based on events.The sequence of events for a system that uses interrupts is different from that of one that doesn't. Consider the __start routine. It does not know how the print routine works. All it knows is that when the print routine returns, the contents of the string will have been printed. This is the model that we are used to. Now consider the print routine. It knows that when the terminal is ready to take more characters it will interrupt. Therefore, all it has to do is make sure that it does not overflow the output buffer. Note that several complications can arise in this situation that we are not used to dealing with.
Supply the code that retrieves a character from the buffer and stores it into the transmitter data register. (Make sure it is consistent with the code that adds a character to the buffer.) Correct code should produce an endless sequence of lines saying "CS 61C is cool!" as output.
- Remember to type
stty min 1
at the unix prompt so that unix doesn't confuse you with its buffered
output scheme.
- Don't forget to run spim with the -memio and -quiet flags.
Remember, the -quiet option tells spim not to call the trap handler
when an exception occurs. This is critical because YOU are supposed
to be handling exceptions. However, while you are writing your code,
you may get some nasty bugs that crash spim. Often, these are
excetions that you are causing and not handling. For example, if you
try to write a word to an unaligned address in spim and the trap
handler is disabled, you will probably get a bus error. So, if you
get a bus error or a seg fault while running spim, try running it
without the -quiet option and you will probably discover the problem.
Remember to turn the -quiet option back on after you debug the
problem.
Problem 2: Virtual Memory
P&H 7.32, and 7.35 (use simple ascii art for problems that ask you
to draw)
Problem 3: More Virtual Memory
A virtual memory address has a page size of 1024 words, 8 vitual pages, and
4 physical page frames. The page table is as follows:
Virtual Page Number Page Frame Number
0 1
1 0
2 3
3 -
4 -
5 2
6 0
7 -
a. What is the size of the virtual address space? (How many bits in a virtual
address?)
b. What is the size of the physical address space? (How many bits in a physical
address?)
c. What are the physical addresses corresponding to the following decimal
virtual addresses (convert decimal to binary): 0, 5596, 1023, 1024, 3728, 4096, 7800? (if any cause page faults, just write page fault)