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.

 

  1. Consider the system calls implemented in hw2, using “int $0x80” as the system call instruction.
  1. How is the system call number specified?

 

  1. What is saved on the stack by this system call instruction?

 

 

  1. 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.

  1. Is IF=0 or IF=1 at this moment?

 

  1. 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?

 

 

 

 

 

  1. A major goal of modern operating systems is user-kernel separation.
  1. Why is this important?

 

 

 

 

  1. 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?

 

 

 

 

 

 

 

 


 

  1. We have seen the need for mutual exclusion (mutex) even in hw1, a single-program system. 
  1. Explain this need—what could happen, and by what execution scenarios?

 

 

 

 

  1. Explain how we provided mutex.

 

 

 

 


 

  1.  [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. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. 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.

 

  1. How many stacks are there in the user process image?
  2. Find the points at which a worker could block, and similarly, where the dispatcher could block (which lines of code?  mark them below)
  3. 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.
  4. 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);

}