=========================preview======================
(COMP252)Fall2005_midterm-sol.pdf
Back to COMP252 Login to download
======================================================
Lecture Section
Dept. of Computer Science, HKUST (circle one below)
COMP 252 Principles of Systems Software 1 2 3
Fall Semester 2005

Midterm Examination
Date: October 22, 2005 (Saturday) Time: 6:00 pm - 7:30 pm (1. hours)

Name: ____SOLUTION_________ Student ID: _______________ Email: ____________________
Instructions:
1.
Please write your name, student ID, and email address on this page. Read the following instructions carefully.

2.
This is a CLOSED book exam!

3.
This examination paper consists of 7 questions and 7 pages (including this page).

4.
You have 90 minutes to complete this exam.

5.
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.

6.
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.

7.
Show all the steps used in deriving your answer, wherever appropriate.


Question Points Score
1 10
2 10
3 10
4 15
5 15
6 20
7 20
Total 100

1. (10 points) Answer the following questions in two or three sentences each:
a) Give two main features of a time-sharing system.
Answer: any two (1 point each)

1.
many programs simultaneously resident in memory

2.
CPU switching among active programs frequently

3.
provides interactive computing environment for users


b) What are two differences between a (software) trap and an interrupt?
Answer: (1 point each)

1.
interrupt is hardware generated while trap is software generated

2.
interrupt can be asynchronous while a trap is synchronous to instruction execution


c) State two major goals of an operating system.
Answer: (1 point each)

1.
Make the computer system convenient to use (the virtual machine)

2.
Use the computer hardware in an efficient manner (the resource manager)


d) Give one advantage and one disadvantage of the one-to-one model for threads.
Answer: any one of advantages (1 point each)
Advantage: Provides more concurrency as it allows another thread within the same process to run even if a thread of the process makes a blocking system call Advantage: Allows multiple threads to run in parallel on multiprocessors Disadvantage: Creating threads is expensive as creating a user thread requires the help of OS
to create a corresponding kernel thread
e) State the three major requirements that any solution to the critical section problem must satisfy? Answer: (1 point each) as long as they mention all three. Deduct . point for each missing.
Mutual exclusion, progress and bounded waiting
2. (10 points) In the following program, what will be the output at line A and Line B? Explain your answer giving suitable reasons.#include <sys/types.h>#include <stdio.h> #include <unistd.h>
int value = 5;
int main(