Next: About this document ...
Ceng 328 Operating Systems
Midterm
April 7, 2006 10.40-12.30
Good Luck!
Part A. Short Answer, answer the questions with one or two sentences (each 5 pt)
- Discuss and compare
- i
- Single Programming,
- ii
- Pure Multiprogramming,
- iii
- Multiprogramming.
.
- What is the purpose of the command interpreter? Why is it usually separate from the kernel?
- For each of the following system calls, give a condition that causes it to fail: fork and exec.
- A computer has six tape drives, with n processes competing for them. Each process may need two drives. For which value of n is the system deadlock free?
Part B. Not Short Answer, you may answer the questions more than two sentences (each 7.5 pt)
- An operating system runs in privileged mode, a hardware state where it has full access to machine resources. Why is such a mode needed, and why can't normal user processes and threads enter privileged mode?
- What advantages do threads have over multiple processes? Suggest one application that would benefit from the use of threads?
- What is a race condition?
- What is a Critical Region? List and explain the four conditions that need to be satisfied to solve the critical-region problem?
- Does the busy waiting solution using the turn variable (strict alternation) work when the two processes are running on a shared-memory multiprocessor, that is, two CPUs, sharing a common memory?
- What is meant by the term context switch? What might cause a context switch to occur?
- What is starvation, give an example?
- 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.
- a
- What is the average turnaround time for the jobs, assuming a shortest-job-first (SJF) scheduling policy?
- b
- What is the average turnaround time assuming a longest-job-first (LJF) policy?
- c
- Which finishes first, Job C in SJF or Job A in LJF?
- Describe the priority scheduling algorithm. Discuss what issues need to be consider to achieve good performance from this algorithm.
- Describe four ways to prevent deadlock by attacking the conditions required for deadlock.
Part C. (each 15 pt)
- 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
2007-03-28