Next: About this document ...
Ceng 328 Operating Systems
Midterm
April 2, 2009 16.40-18.30
Good Luck!
Answer all the questions.
- (5 pts) What are the two main purposes of an operating system?
- (5 pts) What is an ``atomic'' operation? Give an example.
- (10 pts) What is the purpose of system calls? For each of the following system calls, give a condition that causes it to fail: fork and exec.
- (10) Processes (or threads) can be in one of three states. For each of the following three examples, write down which state the process (or thread) is in:
- i
- Waiting in domain Read() for a message from some other process to arrive.
- ii
- Spin-waiting for a variable to become non-zero.
- iii
- Having just completed an I/O, waiting to get scheduled again on the CPU.
- (10 pts) A mechanism that can be used for synchronization is the ability to turn on and off interrupts.
- iv
- How can you use this to implement a critical section?
- v
- Why does it work?
- vi
- Why is this generally a bad idea?
.
- (10 pts)
- vii
- Why is the process table needed in a time sharing system?
- viii
- Is process table also needed in personal computer systems in which only one process exists, that process taking over the entire machine until it is finished?
.
- (10 pts) In a system with threads, is there one stack per thread or one stack per process when user-level threads are used? What about when kernel-level threads are used? Explain.
.
- (10 pts) For a workload consisting of ten CPU-bound jobs of all the same length (each would run for 10 seconds in a dedicated environment);
- which scheduling policy would result in the lowest average response time?
- which scheduling policy would result in the lowest turnaround time?
- (10 pts) Three jobs (A, B, and C) arrive to the job scheduler at time 0. Job A needs 10 seconds of CPU time, Job B needs 20 seconds, and Job C needs 30 seconds.
- ix
- What is the average turnaround time for the jobs, assuming a shortest-job-first (SJF) scheduling policy?
- x
- What is the average turnaround time assuming a longest-job-first (LJF) policy?
- xi
- Which finishes first, Job C in SJF or Job A in LJF?
.
- (10 pts) What is Mutual Exclusion? Describe the ``Strict Alternation'' as a solution for Mutual Exclusion?
.
- (20 pts) The Readers and Writers Problem models access to a database with many competing processes wishing to read and write it. It is acceptable to have multiple processes reading the database at the same time, but if one process is updating (writing) the database, no other processes may have access to the database, not even readers. Write pseudo code to coordinate the readers and writers.
Hints: Need a global counter, rc, for the number of processes reading or wanting to. Use 2 semaphores - one for controlling access to rc, one for controlling access to the database.
Next: About this document ...
Cem Ozdogan
2009-04-06