=========================preview======================
(comp252)[2008](f)mid~PPSpider^_10188.pdf
Back to COMP252 Login to download
======================================================
COMP 252 Operating Systems
Fall Semester 2008
Midterm Examination Solution
Date: Oct 24, 2008 (Friday) Time: 7:00 - 9:00 pm (2 hours)
Name: ____________________ Student ID: __________________
Email: ____________________ Lecture Section: ______________
Note: Please write your name, student ID, and email address on this page. Read the following instructions carefully.
1. This is a CLOSED book exam!
2. This examination paper consists of 5 questions and 8 pages (including this page).
3. You have 120 minutes to complete this exam.
4. Answer all questions within the space provided on the examination paper. You may use back of the pages for your rough work. Be concise! This is NOT an essay contest.
5. Please read each question very carefully and answer the question clearly to the point. Make sure that your answers are neatly written, legible, and readable.
6. Show all the steps used in deriving your answer, wherever appropriate.
Question
Points
Score
1
14
2
20
3
25
4
26
5
15
Total
100
1. (14 points) OS Fundamentals and Structure
1) (4 pts) Modern operating systems are all dual-mode; what are the dual-mode operations, and why is this needed?
Answer: dual-mode refers to the user mode and the kernel mode (1 pt each). This is needed as certain instructions can only be executed in the kernel mode for protection (2 pt).
2) (6 pts) In OS design, what is a policy and what is a mechanism? Can you give one advantage for this separation?
Answer: Mechanisms determine how to do something (2 pt) and policies decide what will be done (2 pts). This separation is necessary for flexibility so to minimize the changes needed when either policy or mechanism is changed (2 pts).
It is also ok to say, that a policy defines the functionalities and mechanisms specifies the implementation.
3) (4 pts) What do we mean by multi-programming operating system? What is the main advantage of such an operating system?
Answer: It allows multiple processes (jobs) to run concurrently in the system (2 pts). This improves the CPU utilization (1 pt).
2. (20 pts) Processes and Threads
1) (3 pts) Can you name three possible states that a process can have?
Answer: new, ready, running, waiting, terminated. PCB is used (1 pt each)
2) (3 pts) A process can be in various states, in which OS manages that by putting them on different queues. Can you name three common queues that OS uses?
Answer: ready queue, job queue, device queue, queue for a synchronization signal, queue for a semaphore and etc.
3) (8 pts) Consider the program segment with fork() instruction below, and suppose each process can run to completion, i.e., no interrupt in the middle of a process execution. Please answer the following two questions.
main ()
{ int x;