=========================preview======================
(COMP252)[2010](f)midterm~=bxrzkjdm^_74450.pdf
Back to COMP252 Login to download
======================================================
HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY
Operating System (COMP 252)
Fall Semester, 2010
Midterm Examination
7:00 pm C 8:30 pm October 22, 2010
Name: Student ID:
Email: Lecture Section:
Instructions:
1.
This examination paper consists of 10 pages, with 6 questions.
2.
Please write your name, student ID, email and lab section on this page.
3.
Please answer all the questions in the space provided.
4.
Please read each question very carefully, answer clearly and to the point. Make sure that your answers are neatly written.
5.
Keep all pages stapled together.
6.
This isa 1.5 hours exam.
7.
Please fill in your student ID at the top of every page.
Question Scores Your Grades
1 7
2 8
3 16
4 14
5 30
6 25
TOTAL 100
Question 1 OS Fundamental and Structure (7 points)
1) What is a trap? How is a trap used in OS? (4 pts)
Answer:
A trap is a software-generated interrupt (2 pt). This is used to call OS routine (2 pts). It is fine to answer, to initial system calls, or to catch arithmetic errors.
2) What is the main advantage in Microkernel OS design? (3 pts)
Answer:
It provides portability due to a small kernel.
Question 2 Thread (8 points)
1) Which of the following component(s) in a program state that is/are shared by the threads within a multithreaded process? (4 pts)
a.
Register values
b.
Heap memory
c.
Global variables
d.
Stack memory
Answer:
The threads of a multithreaded process share b) Heap memory and c) Global variables. (2 pts each)
2) What are the active and passive entities in a process (4 pts)
Answer:
The thread is the active entity (2 pts). Data, code and files are passive entities (2 pts)
2
Question 3 Scheduling (16 points)
1) The CPU scheduling can take place under the following four circumstances:
1.
When a process switches from the running state to the waiting state;
2.
When a process switches from the running state to the ready state;
3.
When a process switches from the waiting state to the ready state;
4.
When a process terminates.
Under what circumstance(s), the non-preemptive scheduling can occur? (2 pts)
Answer:
1) and 4)
2) What problem can occur when a priority-based scheduling algorithm is used, such as Shortest-Job-First (SJF) scheduling? What mechanism can be used in priority-based scheduling to deal with the problem? Please briefly explain the mechanism. (4 pts)
Answer:
Starvation (1 pts).
Aging (1 pts).
Time progress increases the priority of the process (2 pts).
3) Consider the following set of processes, with the information of arrival times and the CPU burst lengths: (10 pts)
Process Arrival Time Burst Time
P1 0 10
P2 6 7
P3 8 13
P4 12 4
(a) Please construct a Gantt chart depicting the scheduling for the set of processes, given that