Operating Systems Qualifying Examination
January 11th, 1999 -- 12-16pm
1. It should be possible to implement general semaphores using binary semaphores. We can use the operations waitB and signalB and two binary semaphores, delay and mutex. Please consider the following example:
procedure Wait(var s, semaphore); begin WaitB(mutex); s = s -1; if s < 0 then begin SignalB(mutex); WaitB(delay); end; else SignalB(mutex); end; procedure Signal(var s: semaphore); begin WaitB(mutex); s = s + 1; if s ¾ 0 the SignalB(delay); SignalB(mutex); end;
At first, s is set to the desired semaphore value. Each Wait decrements the semaphore s, and each Signal increments it. The binary semaphore mutex, which is initially set to 1, assures that we have mutual exclusion for the operations on s. The binary semaphore delay, which is initialized to 0, is used to suspend processes. Looks great - eh? Well, there is a serious flaw in the code provided above. Your task is to find and explain the flaw and then to suggest the change in the code that will remedy it. Hint: The number of lines of code that must be changed is quite small.
2. We generally agree that the following are valid reasons to use threads in processes.
Please describe at least two other reasons that threads are an attractive alternative to "forking" off new processes.
3. Consider a UNIX file system represented by the following skelital INODE:
file name date created date modified ... block 0 pointer (direct) block 1 pointer (direct) ... block 11 pointer (direct) singly indirect block pointer doubly indirect block pointer triply indirect block pointer
Assume also that the disk sector and block sizes are both 8K. If the disk pointers are 32-bits with 8 bits to identify the physical disk and 24 bits to identify the physical block, then
4. What sorts of file organization would you choose to get the best speed of access, use of storage and ease of updating when the data are
5. Most round robin schedulers used fixed size quanta.