Keys to Some of the Exercise questions --------------------------------------- 2. Specify the hardware support necessary for memory protection, and explain briefly how it works. The system should provide some kind of hardware support to keep track of which parts of memory are currently being used and by whom, to make sure that a process does not access the memory being used by other processes. (Discused in Section 1.7) 3. State the correctness criteria for the producer-consumer problem. (1) No underflow: consumer must wait for producer to fill buffers. (2) No overflow: producer must wait if all buffer space is in use. (3) Only one process must manipulate buffer pool at once. 4. Write down a solution of the Producer-Consumer problem using monitor. Let N be the buffer size. Monitor Producer-Consumer int buffer[N], item, count condition full, empty Put_it(item) while (count == N) wait(full) {put item into the buffer} count = count + 1 if (count == 1) signal(empty) Grab_it() while (count == 0) wait(empty) {get item from buffer} count = count - 1 if (count == (N-1)) signal(full) endmonitor Producer -------- while (true) {generate (item)} Put_it(item) Consumer -------- while(true) Grab_it() {consume (item)} 6. Synchronization has two parts: mutual exclusion and scheduling. Discuss how they are provided in monitors. ME is autoimatically providede by the monitor lock. Scheduling is provided by the condition variables. 7. Draw the state transision diagram of a process and indicate which transition can be incurred by wait and signal operations of a monitor. Running -> Blocked: P or waiting for event Blocked -> Ready: V or event occurs 8. In the semaphore solution of readers/writers, can OKToWrite ever get greater than 1? What about OKToRead? Explain how it can (or cannot) happen. OKToWrite cannot be great than 1. OKToRead can be great than 1. 9. In the monitor solution of readers/writers, is FIFO order guaranteed for Writers (i.e., the first writer who calls checkWrite will go into the database before other writers who call checkWrite later)? FIFO is not guaranteed. 10. Regarding the monitor solution of readers/writers, if the first writer (P1) is inside the doneWrite procedure when the second writer (P2) arrives to the system, how far can it go within the checkWrite procedure? P2 is not going anywhere; it is waiting for the monitor lock at the entrance of the monitor.