=========================preview======================
(COMP252)2007Mid-term_Ans.pdf
Back to COMP252 Login to download
======================================================
COMP 252 Operating Systems
Fall Semester 2007
Midterm Examination Solution

Date: Oct 26, 2007 (Friday) Time: 7:00 - 9:00 pm (1. hours)
Name: ____________________ Student ID: __________________
Email: ____________________ Lecture Section: ______________

Note: This solution consists of 7 questions and 7 pages (including this page).
Question Points Score
1 24
2 24
3 12
4 10
5 10
6 10
7 10
Total 100

1. (24 pts) OS Fundamentals and Structure
1) (5 pts) What are the two modes in the dual mode of operation? What is its purpose? Name one instruction that should be enabled in one mode but not in the other.
Answer: user and kernel modes (2 pts). The dual mode operation allows OS to protect itself and other system components (2 pts). All privileged instructions can only be executed in the kernel mode (e.g., I/O control, timer management, interrupt handler) (1 pt)
2) (4 pts) In OS design, what is a policy and what is a mechanism?
Answer: Mechanisms determine how to do something (2 pts) and policies decide what will be
done (2 pts)
It is also ok to say, that a policy defines the functionalities and mechanisms specifies the
implementation.
3) (4 pts) Name four types of storage in the storage hierarchy.
Answer: register, cache, main memory, disk (electronic, optical, magnetic), tape (any four of
them)
4) (4 pts) What are system calls? How are they related to the concept of dual-mode
operation?

Answer: A system call is used by an application program to invoke a function provided by the operating system (2 pts). Typically, the system call results in a context switch from the user mode to the kernel mode (2 pts).
It is ok to say that system calls allow a running program to make requests from the OS directly.
5) (3 pts) What is the key difference between the layered approach and the modular approach to kernel design?
Answer: In the layered approach, one layer can only call its layer below; in the modular approach, any two modules can communicate with each other (directly)
6) (4 pts) Name one key benefit and one key drawback of the virtual machine approach.
Answer:
Benefits: isolation and protection of system resources (2 pt) or good environment (vehicle) for
OS research, development and debugging (2 pt)
Drawback: no direct resource sharing; difficult to implement, slow performance (any one of
the three 2 pt).


2. (24 pts) Processes and Threads
1) (4 pts) Name one key benefit and one key drawback of the many-to-one multithreading model compared to the one-to-one model.
Answer:
Benefit: low overhead of thread creation or efficient thread management by user library (2 pts) Drawback: can not achieve concurrency or unable to run in parallel on multi-processors (2 pts)
2) (4pts) Explain the key drawback of spinlock semaphores compared to semaphores with no busy-waiting.
Answer: Spinlock semaphores incur busy waiting (2 pts), and thus can waste CPU cycles