0% found this document useful (0 votes)
15 views

Second (2)

Uploaded by

Mais Arafeh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Second (2)

Uploaded by

Mais Arafeh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PALESTINE POLYTECHNIC UNIVERSITY

COLLEGE OF INFORMATION TECHNOLOGY AND COMPUTER ENGINEERING


OPERATING SYSTEMS 7505
SECOND EXAM - SEMESTER 2 - 2023
Student Name: _________________________ ___:)‫________________________االسم (عربي‬
Date: Wednesday 19/04/2023 Student Number: _____________________
Time: 50 Minutes Section: _____________________________
Q1 (30 points) Q2 (30 points) Q3 (20 points) Total

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]);

This could cause:


A) Definite Wait.
B) Deadlock.
C) Starvation but not Deadlock.
D) No problem (code is correct).
11. A counting semaphore was initialized to 10. Then 6 (wait) operations and 4 (signal) operations were
completed on this semaphore. The resulting value of the semaphore is
A) 10 B) 6
C) 8 D) 4
12. Process synchronization can be done on which of the following levels
A) hardware.
B) software.
C) both hardware and software
D) none of the mentioned.
13. In which the access takes place when different processes try to access the same data concurrently and the
outcome of the execution depends on the specific order, is called
A) dynamic condition
B) race condition
C) essential condition
D) critical condition
4. 14. In the following RAG figure, this system
A) Is Deadlocked
B) Maybe Deadlocked
C) No Deadlocked
D) Race Conditioned with Mutual Exclusion

. 15. In the following RAG figure, If P1 requests its claim, then


A) This request will be granted immediately to P1
B) P1 should wait until P2 finished is usage of resource R1.
C) The system will be in unsafe state and request is not granted.
D) The claim edge will be converted to request edge for P2 first.
.

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)

Process Burst Time Priority Arrival Time


(when needed)
P1 10 3 1
P2 1 1 3
P3 2 5 2
P4 1 4 4
P5 5 2 18

FCFS RR, q=3 RR, q = 10 SRT with CS =1)


(preemptive)
Avg WT 29 / 5 12 / 5 29/5 20 /5
Avg TAT 48 / 5 31 / 5 48 / 5 40 / 5
Ucpu
(NO Calculator) 19 / 23 19 / 23 19 / 23 19 / 26

Show your work using the following Template Gant Charts (Only table answers will be considered)

FCFS // | P1 | P3 | P2. | P4 | ////////// | P5 |


1 11 13 14 15 18 23
WT = (1-1 +13-3 +11-2 +14-4 + 18-18) /5 =( 0+10+9+10+0 ) /5 = 29 /5
TAT = (11-1 + 14-3 + 13-2 +15-4 + 23-18 ) /5 = (10+11+11+11+5) / 5 =48 /5

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

RR -Q=10 Larg q = 10 ……. Same as FCFS

SRT with
CS =1) //| P1 | // | // | P2 | // | P4 | // | P3 | // | P1 | // | P5 |
(preemptive)
1 2 3 4 5 6 7 8 10 11 20 21 26

WT = (1-1 + 11-2 +4-3+8-2+6-4+21-19) /5 =( 0 + 9 + 1 +6 +2 + 2 )/5 =20 /5


TAT = (20 -1 + 5 – 3 + 10 -2 + 7-4 + 26 – 18) /5 = ( 19 + 2 + 8 + 3 + 8 ) /5 = 40 /5 =

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.

Shared int Size= 100


Shared Int Semaphore W_Mutex = 1

N1 neighbors N2 neighbors

Do{ Do{

If Adding water If Adding water


{ {
Wait(W_Mutex) ; Wait(W_Mutex) ;
Size = Size + 5; Size = Size + 5;
Signal(W_Mutex) ; Signal(W_Mutex) ;
} }
If Taking water If Taking water
{ {
Wait(W_Mutex); Wait(W_Mutex);
Size = Size – 5; Size = Size – 5;
Signal(W_Mutex); Signal(W_Mutex);
} }
}While true }While true

OR

Shared int Size= 100


Shared Int Semaphore W_Mutex = 1

Adding Water Processes Removing Water Processes


Do{ Do{

Wait(W_Mutex) ; Wait(W_Mutex);
Size = Size + 5; Size = Size – 5;
Signal(W_Mutex) ; Signal(W_Mutex);

}While true }While true

You might also like