CS444 Previous Midterm Exam, for practice, F06
Open books, notes, handouts.
Write on these pages, using the backs
if need be (I hope
not.)
Each problem is worth 20 points.
- Consider the
system calls implemented in hw2, using “int $0x80” as the
system call instruction.
- How is the system
call number specified?
- What is saved on
the stack by this system call instruction?
- What is specified
by the 0x80 number, i.e., what would we have to change in tunix.c if we switched to
“int
$0x90” as the system call instruction?
Continue
to consider hw2’s system,
in execution. Suppose
the UART
transmitter becomes ready to accept another byte while the user program
is
running.
- Is IF=0 or IF=1 at
this moment?
- After the
interrupt happens in the CPU, what software function (assembler or C)
first executes? Which
one last executes, just before the user program resumes execution?
- A major goal of
modern operating systems is user-kernel separation.
- Why is this
important?
- Compare the hw2
system with Solaris or Windows 2000, both of which have very good
user-kernel separation: what do we
have in hw2 in this direction and what is missing in our setup?
- We have seen the
need for mutual exclusion (mutex)
even in hw1, a single-program system.
- Explain this
need—what could happen, and by what execution scenarios?
- Explain how we
provided mutex.
- [Not
coverd yet F06, so skip] A system has two processes, A and B, and three
identical resources. Each
process needs a maximum of two resources.
Show that deadlock is impossible.
One way: let x be the number of resources A has and y
the number for B. What
does the hold condition tell us? The
waits-for condition? Then
show an unwinding for the only possibility.
- Consider the
multi-threaded Web server described in Tanenbaum
on pg. 88, and assume kernel-supported threads are in use. Suppose there are 5 worker
threads.
- How many stacks
are there in the user process image?
- Find the points at
which a worker could block, and similarly, where the dispatcher could
block (which lines of code? mark
them below)
- Where must there
be an action that does an unblock
(there’s only one spot in this
code that has to have an unblock action.)
Again, mark that line in the code.
- Why is a pointer
(&buf)
sufficient as communication between the dispatcher and the
worker—why can they use the same
pointer value to access the buffer?
/* dispatcher */
while (TRUE) {
get_next_request(&buf);
handoff_work(&buf);
}
/* worker */
while (TRUE) {
wait_for_work(&buf);
look_for_page_in_cache(&buf,
&page);
if (page_not_in_cache(&page))
read_page_from_disk(&buf,
&page);
return_page(&page);
}