Sample midterm exam

Problem 1

In a multi-process system, at any moment every process is in
one of three states: running, ready, or blocked. What are the transitions
between these states, and when do they occur?

Problem 2:

Explain briefly (1 or 2 sentences) the major difference
between a thread and a process. Name one type of state that is recorded
in a thread table. Name one type of information that is saved in
a process table but not in a thread table.

Problem 3

(Multiple choice: Give all correct answers)
Suppose there are two processes, A and B, which share semaphors
R and S. At the starting time, R = 0, S = 1. A and B are entering the
sections of code shown below:

Problem 4:

Problem 5

A. A section that is executed very often, and therefore should
be written to run very
efficiently.

B. A section of the program that must not be interrupted by the
scheduler.

C. A section of the program that is susceptible to race conditions,
unless mutual exclusion is enforced.

D. A section of the code executed in kernel mode.

Problem 6:

(Multiple choice: Give all correct answers)
A given OS uses round-robin scheduling. The time quantum
is Q and the time needed for context switch is C. Over an extended
time period T, which is much greater than Q+C, there are
N active processes; no processes begin or terminate during this period.
Assume further that all these processes fit together in memory; no
swapping or paging is needed.
Which of the following statements are true:

A. All processes get an equal share of the CPU.

B. If process P is ready, then it will be scheduled to run within time
NC + (N-1)Q.

C. If process P has just exhausted its time quota, then it will have to
wait for at least
time NC + (N-1)Q.

D. If process P is running and blocks, and process W is currently ready
then W will be
run before P runs again.

E. The efficiency of the system --- that is, the fraction of time that the
CPU is executing
a process --- is always equal to Q/(Q+C).