CS644 Final Exam. for practice, S10
Open books, notes, handouts. You can write short answers on these papers and longer ones on the backs of pages or on other paper. Points: problem 1 = 40pts, 2=40pts, 3=30pts, 4=40pts.
1. Shorter Answer: Assume Linux 2.6, as in the text.
a. What Linux function corresponds to resched() in Xinu?
b. What is done in Xinu system call code to block the current process (give the 2 lines of code)?
c. What is done in Linux system call code to block the current process (give example lines of code—there is more than one way)?
d. What is done in Xinu system call code to unblock another process? In interrupt handler code?
e. Interrupts are allowed in a greater part of Linux kernel code than in Xinu kernel code. Explain why, referring to kernel mutex mechanisms.
f. Can interrupt handlers block—in Linux? In Xinu?
g. Both Linux and Xinu have clock interrupt handlers. List two actions they do in common.
h. What specific mechanism prevents user-level code from accessing kernel memory in 32-bit x86 Linux, which holds the kernel in the uppermost 1GB of the 4GB virtual address space?
2. Consider the following Linux memory areas:
KGD kernel global data, not including per-process data
KS kernel stack
PENT process entry (task_struct)
UI user image: code, data, stack, etc.
a. Which of these areas are per-process, so that each process on the system has one?
b. Which of these areas are process-private?
c. Which areas allow update of their contents by the kernel without needing mutex?
d. Which one can be empty for an active currently-running process?
e. In which area are the serial line input buffers?
f. In which area is the semaphore table, underlying System V semaphores?
g. In which area is the C library code used by the user process?
3. Recall the mloop program of hw4. Suppose it is running with 3 worker processes (pids 40, 41 and 42) and using the original send/receive, and using sleep100(5) for delay, that is, 50 ms delay between receiving and sending the message around the loop. The clock tick is 10 ms on Xinu.
a. Suppose the last send was 25 ms ago by process 41, plenty of time for the system to settle down to a certain state. What are the pstate values for the three worker processes?
b. What do you expect to see on Xinu's clockq at this time? Give the key value(s) on the delta queue.
4. Projects—do one of these.
Printer driver
Suppose two processes are trying to print at the same time. Process A is printing 1000 A’s and process B is printing 1000 B’s. Process A calls write(LP, buf, 1000) first, followed as soon as possible by process B, using another user buffer. No other user processes exist. Suppose the printer output buffer can hold 100 characters. Assume lpwrite is just a loop of lpputc’s with no kernel mutex of its own (which is fine, since lpputc is itself the guts of a system call and thus takes care of its mutex needs.)
a. In general, explain how the printer driver controls all this data going through it and ensures that 2000 characters are printed.
b. In particular, what happens when process A calls write, up to the moment it loses the CPU—
i. With a full quantum remaining, so it can do a lot of processing without preemption.
ii. With a small amount of CPU remaining in its quantum, enough for 2 lpputc’s.
Don’t forget to discuss the common elements of the execution, such as getting the printer started.
c. Consider a moment later when both processes have called write and the printer output buffer is full, and the printer is currently (slowly) outputting a character. List all the processes on the system, including process 0, and their current process state.
IPC Datagram Service
The datagram service is handling two user-level server processes on a Xinu system. One is waiting for datagrams on port 100 and the other on port 200.
a. Before any client processes come into existence, list all the processes on the system, including process 0, and their current process state.
b. Suppose two user processes come into existence to be clients of the server on port 200. Explain how it could happen that they are both executing in dgram_send at the same time, that is, their current or saved EIP (in pregs in pentry) is in dgram_send.
c. Consider the two processes described in b that are both executing in dgram_send to port 200. In general, explain how the datagram service ensures that their client interactions with the service occur in an orderly fashion, even if two datagrams destined for the same port exist in the system at the same time.
d. Continuing from part c., the server on port 200 can receive the datagrams with dgram_receive. How does the server tell one client from another?