CS444 Previous Midterm Exam,
Open books, notes, handouts.
Write on these pages, using the backs if need be (I hope not.)
Each problem is worth 20 points.
in eax
EIP
(also known as PC), EFLAGS. (also
CS, the code segment descriptor, but we ignore segment
registers in this class)
This is
the index in the IDT of the trap vector.
We would have to change set_trap_gate’s
first
argument in tunix.c
Continue to consider hw2’s system, in execution. Suppose the UART transmitter becomes ready to accept another byte while the user program is running.
IF = 1 in
user code, always
the
assembler
interrupt handler, irq3inthand, first and last.
It is
crucial for systems security. No
user
code can harm the kernel image or even read it.
Both hw2
and Solaris/Windows2000 use system call instructions to control the
user-kernel
transition.
In hw2,
we don’t run the user code at user mode in the CPU as is done
in the real OS’s,
so the user code could do privileged instructions in
hw2.
The input
and output buffers/queues of the tty
driver are shared between ttyread/ttywrite
and the
corresponding input and output interrupt handlers.
With no mutex,
an interrupt could occur half way through an enqueue
in ttywrite and do a dequeue
on the same data
structure, breaking it.
(or
half way though a dequeue
in ttyread, an input
interrupt handler execution could enqueue
on the same queue, breaking it.)
By
turning off the interrupt system, cli(), to set the mutex, and turning
it back on to release the mutex.
The
hold condition requires x >= 1, y >= 1.
The
waits-for conditions requires x < 2, y < 2, so they
don’t yet have
everything they want.
Thus x
= y = 1.
Unwinding. There is one
unit available. Assign
it to A, finish A, free both. Then
there are two units available, and B can
easily finish.
Pointer values are memory addresses in the user image, and all threads operate in the same process image, so have access to the same user addresses.
/* dispatcher */
while (TRUE) {
get_next_request(&buf); ß
can block
handoff_work(&buf); ß
unblocks worker
}
/* worker */
while (TRUE) {
wait_for_work(&buf); ß can
block
look_for_page_in_cache(&buf,
&page);
if (page_not_in_cache(&page))
read_page_from_disk(&buf,
&page); ß
can block
return_page(&page);
}