Operating Systems Midterm Exam My answers...


1a. [5] How does SandBox deal with multiple simultaneous interrupts?

The first one recognized is processed with all interrupts disabled, then when it finishes, the next one recognized is taken. There is an implied priority (clock will always take precedence over for example the printer), but only one level of disabling.


1b. [5] What is another good way to deal with them?

Many CPUs have prioritized interrupt levels, so a higher priority interrupt can interrupt the handling of a lower level.


2. [10] Describe the procedure call protocol in a computer you are familiar with. Compare and contrast that with interrupts on the same computer.

Several people thought this question was about context switching or system calls. It's actually the exact wording from the study guide for Appendix 1B, which deals with calling subroutines within a program.

The SandBox procedure call protocol pushes onto the stack a place to hold the return value, then the arguments, then a copy of the globals pointer; then a Call to a subroutine number is issued which pushes the PC and replaces it with a value calculated from the subroutine table. The subroutine pushes the number of local variable words and issues an enter instruction to push the FP and replace it with a new FP pointing to the globals pointer, then adds the locals value to the SP. On exit, the FP and PC are restored from their saved values, and a specified number of parameters are popped from the stack. The caller finally stores the return value.

Interrupts are like involuntary procedure calls, except that the entire context is saved and restored (and there are no parameters).


3. [15] Diagram and label a ž5-state process modelÓ

From the textbook:


4. [8] Explain žexecution modesÓ in the context of SandBox. How are other processors different?

Execution modes generally refers to the difference between User Mode and Supervisor Mode in most CPUs, where system-level instructions can only execute in Supervisor Mode. SandBox makes no such distinction


5. [12] List the elements of a context switch that are essential in all systems:

The current context -- basically all registers and system services (such as MMU table and maybe open files) that are particular to this process must be saved in the PIB or else on the process stack (as in SandBox),

Then the process must be disconnected from "current" and linked into the ReadyList or whatever blocked (semaphore) list it will be waiting in,

Then a different process must be unlinked from the ReadyList, and

Finally, its saved context reloaded into the CPU registers, thus starting it up.


6. [15] Describe three different ways to support concurrency, giving enough detail to explain how they are different:

a.  The SandBox has hardware support for Semaphores, which use Signal and Wait to allow concurrent processes or threads to synchronize their activity. A process blocks waiting on a semaphore until some other process signals it, which releases one waiting process to run again.

b. With Monitors, only one process at a time is permitted into a critical region controlled by the monitor. Java works this way.

c. Message-Passing essentially works without the requirement for shared memory, and synchronization is achieved by sending messages back and forth. A process may wait on receiving a message, but this is optional.
 

7. [20] True or False:

__F__ a. Semaphores are signalling devices to start and stop interrupts

No, they start and stop User processes.
__F__ b. žSegmentation FaultÓ is the result of a memory manager paging failure
No, it's a result of a segmentation failure. Segments are not the same as pages.
__T__ c. žBuddy SystemÓ is a strategy for making bigger memory blocks
out of smaller blocks that were allocated as "buddies", thus preventing fragmentation.
__F__ d. A well-designed system can prevent deadlock
No, it only minimizes it. Nothing can completely prevent deadlock.
__F__ e. Monitors are safer than semaphores, because they prevent deadlocks
Nothing prevents deadlocks. Monitors are harder to get wrong than semaphores, but not impossible.
__F__ f. Test-and-set is a form of monitor
No, it's a machine instruction commonly used to implement monitors.
__T__ g. Round Robin is a form of circular queue
Kind of sort of. A circular queue is a place to store data so that the oldest data is taken out first. Round-Robbin is a strategy for allocating the CPU as a resource among the requesting processes, which gives time to the oldest process in the ReadyList.
__F__ h. A microkernel is a small operating system used in old microprocessors
No, it's a small operating system component used in modern OSes.
__F__ i. A good memory management strategy can prevent page faults
No, it actually depends on page faults to work, but it can minimize them.
__T__ j. A coroutine is a way to do concurrency
It does concurrency by voluntary process management.


2004 March 11