Second (2)
Second (2)
Question 1 (30 points) Choose Best answer and fill in the table:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
C B B A B A C A B B C C B C A
1. Select which algorithm tend to minimize the process flow time (waiting time)?
A. First come First served.
B. Earliest Deadline First.
C. Shortest Job First
D. Longest Job First and Round Robin.
2. The process can be classified into many groups in
A. shortest job scheduling algorithm.
B. multilevel queue scheduling algorithm
C. round-robin scheduling algorithm.
D. priority scheduling algorithm.
3. From the time of submission of a process to the time of completion, the interval is termed as
A. waiting time.
B. turnaround time
C. response time.
D. throughput.
4. Under the category of_______ Round-robin scheduling falls into:
A. Preemptive scheduling
B. Non preemptive scheduling.
C. Priority scheduling.
D. None of the mentioned.
5. When several processes access the same data concurrently and the outcome of the execution depends on
the particular order in which the access takes place is called ________
A) dynamic condition.
B) race condition
C) essential condition.
D) critical condition.
6. If a process is executing in its critical section, then no other processes can be executing in their critical
section. What is this condition called?
A) mutual exclusion
B) critical exclusion.
C) synchronous exclusion.
D) asynchronous exclusion.
7. Process synchronization can be done on
A) hardware level.
B) software level.
C) both hardware and software level
D) none of these.
8. Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes?
A) In deadlock prevention, the request for resources is always granted if the resulting state is safe
B) In deadlock avoidance, the request for resources is always granted if the result state is safe.
C) Deadlock avoidance is less restrictive than deadlock prevention.
D) Deadlock avoidance requires knowledge of resource requirements a priori.
9. A system contains three programs and each requires three tape units for its operation. The minimum
number of tape units which the system must have such that deadlocks never arise is _________.
A) 6. B) 7.
C) 9. D) 12.
10. Let m[0]…m[4] be mutexes (binary semaphores) and P[0] …. P[4] be processes. Suppose each process
P[i] executes the following:
wait (m[i]);
wait(m[(i+1) mode 4]);
// Process code …..
signal (m[i]);
signal (m[(i+1) mod 4]);
2
Question 2 (30 points) CPU Scheduling
1. For the set of processes in below table, Fill the following requirements table: (average Waiting
time, average Turnaround Time and Ucpu for each of the following scheduling criteria)
Show your work using the following Template Gant Charts (Only table answers will be considered)
RR-Q=3 // | P1 | P3 | P2 | P4 | P1 | P1 | P1 | ///////// | P5 | P5 |
1 4 6 7 8 11 14 15 18 21 23
WT = (1-1+8-4)+ 6-3 +4-2 + 7-4+ 18-18 ) /5 = ( 4 +3 +2 + 3 + 0 ) /5 = 12/5
TAT = (15-1 +7-3 + 6-2 + 8-4 + 23 -18 ) /5 = ( 14 + 4+ 4+4 + 5) /5 = 31 /5
SRT with
CS =1) //| P1 | // | // | P2 | // | P4 | // | P3 | // | P1 | // | P5 |
(preemptive)
1 2 3 4 5 6 7 8 10 11 20 21 26
3
Question 3: (20 points) :
Assume two neighbors N1 and N2 share the same water WELL. The number of cube
meters in this well is saved in a Size variable initially containing 100 cube meters.
Both neighbors can concurrently add water or take water from the well in a quantum
of 5 cube meters at a time. Use a semaphore (W_Mutex) to synchronize the process
of adding or taking water from the well so as to keep the well size in a consistent
value.
N1 neighbors N2 neighbors
Do{ Do{
OR
Wait(W_Mutex) ; Wait(W_Mutex);
Size = Size + 5; Size = Size – 5;
Signal(W_Mutex) ; Signal(W_Mutex);