COP 4600 Operating Systems
Exam 1 Key
30 September 2011
- System Calls
- How does handling a system call differ from making a call to a library procedure? Explain.
When a procedure call to a library (or a local) procedure, the procedure’s activation frame is pushed on the stack and the program counter is set to the first instruction of the procedure. Parameters are passed through the activation frame. There is no context switch, and the process remains in user mode. When a system call is made, a context switch occurs, so the process’ registers must be saved and the parameters are passed through registers. The system changes to kernel mode and the system call handler interprets the register values to determine which system call is being made, then passes control to the module responsible for handling the call. If this results in a blocking action (e.g., I/O or semaphore), then the scheduler runs to determine the next process to run.
- How does it differ from handling an I/O interrupt? Explain.
When an I/O interrupt occurs, the call is external to the process that is currently running, unlike a system call. Like a system call, a context switch occurs, so the process’ registers must be saved, but no parameters are passed through registers from the process since the process did not make the call. The system changes to kernel mode and the interrupt handler determines what kind of interrupt has occurred, then passes control to the appropriate interrupt handler using the interrupt vector. If the result causes a process to switch from blocked to ready state, then the scheduler runs to determine which process should run next.
- Synchronization
- A system uses virtual memory and has a cache memory with 1 nsec. access time, main memory with 8 nsec. access time, and disk with access time of 10 msec. If the cache hit rate is 90% and the page fault rate (after a cache miss) is 2%, what is the average time to access a word? Show work.
Mean Access Time = 0.9(1 nsec) + 0.1(8 nsec) + 0.1(0.02)(10,000,000 nsec)
= 0.9 + 0.8 + 20,000 = 20.0017 usec
- What offers the better improvement, reducing the cache miss rate by half or reducing the page fault rate by half? Explain.
MAT_1 = 0.95(1 nsec) + 0.05(8 nsec) + 0.05(0.02)(10,000,000 nsec)
= 0.95 + 0.4 + 10,000 = 10.00135 usec
Mean Access Time = 0.9(1 nsec) + 0.05(8 nsec) + 0.05(0.02)(10,000,000 nsec)
= 0.9 + 0.8 + 10,000 = 10.0017 usec
- Threads and Processes
- What are the pros and cons of using a fixed number of worker processes to handle web server requests vs. using dynamic threads to do this? Explain.
M= 0.9(1 nsec) + 0.1(8 nsec) + 0.1(0.02)(10000000 nsec)
- Compare the advantages and disadvantages of user-level vs. kernel level threads.
M= 0.9(1 nsec) + 0.1(8 nsec) + 0.1(0.02)(10000000 nsec)
- Process scheduling
Suppose 6 jobs arrive at times 0, 1, 3, 4, 6, 8, and that they take CPU times 10, 2, 8, 3, 7, and 5, respectively.
- Show the schedule, the turnaround time for each job, and the mean TT for FIFO scheduling.
- Repeat (a) for SJF scheduling.
- Repeat (a) for SRTF scheduling.
- Memory Management
- How do overlays relate to segmentation?
- Why are inverted page tables used? Explain how they work and what problem they solve.
- Suppose your physical memory is 16 MB, your virtual addresses are 32 bits, and your page size is 4 KB. Page table entries are 16 bits each. If one-level paging is used, how big is the page table? If two-level paging is used, how many bits are used for the top-level index? Explain.
- Suppose a sequence of page references is 1 2 3 4 2 5 3 4 2 5 6 2 3 4 2 5 6 1
- What is the number of page faults if FIFO replacement is used with 4 frames? Show when page faults occur and which page is replaced at each fault.
- What is the number of page faults if LRU replacement is used with 4 frames? Show when page faults occur and which page is replaced at each fault.
- What is the least number of page faults possible with 4 frames? Show when page faults occur and which page is replaced at each fault.