Second (3)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

PALESTINE POLYTECHNIC UNIVERSITY

COLLEGE OF INFORMATION TECHNOLOGY AND COMPUTER ENGINEERING


OPERATING SYSTEMS 7505
SECOND EXAM FALL 2019
Time: 58 minutes
Name:______________ NO:________________ Date: Sunday 31/03/2019

(Answer all questions in English only)


NO questions during the exam are allowed.
Q1.1 Q1.2 Q2.1 Q2.2 Q3.1 Q3.2 Q3.3 Q3.4 Q2.2 Total

Question 1 (25: 15, 10 points)


I) Assume a printer buffer of size 10000 characters; assume that the physical printing device
reads characters from the buffer as 100 characters at a time. Also assume that applications
printing to the printer submit characters as 200 characters at a time. Using Semaphores
show how to solve the above synchronization problem between printing applications and
physical printing devices with bounded buffer. Define all used shared and local variables
properly and with proper initializations.

Shared:
Bin Semaphore mutex = 1
Count Semaphore full = 0
Count Semaphore empty = 100;
An Application process A Physical printing process

Do{ Do{
Prepare characters wait(full);

wait(empty); wait(mutex);
wait(empty); remove 100 from buffer;
signal(mutex);
wait(mutex);
add 200 to buffer; signal(empty);
signal(mutex);
print on physical
signal(full);
signal(full); }While (true)

}While (true)

II) Precisely define the critical section problem and race conditions.
 Consider system of n processes {p0, p1, … pn-1}
 Each process has critical section segment of code
o Process may be changing common variables, updating table, writing file, etc
o When one process in critical section, no other may be in its critical section
 Critical section problem is to design protocol to solve this
 Each process must ask permission to enter critical section in entry section, may follow critical section with
exit section, then remainder section
Question 2 (25: 8, 17 points)

I) List the 4 conditions of deadlock to occur.

1. Mutual Exclusive
2. No preemption
3. Hold and Wait
4. Circular Wait.

II) For the following system shot at time T0 answer the following questions:

Allocation Max Need What is the total


ABC ABC A B C number of all
P0 120 753 6 3 3 resources?
P1 0 0 1 132 1 3 1 A B C
P2 3 0 2 802 5 0 0 ____ ___ ____
P3 2 1 1 222 0 1 1
P4 1 0 2 433 3 3 1 9 5 8

Current Available : 2 2 2

1.Is the system safe at time T0? : Show your work: Safety Sequence if any < 3 4 1 2 0 >

433–5 3 5 - 5 3 6 - 8 3 8 - 9 5 8

2. Can a request of 2 instances of resource type C be granted for P2? If yes show safety sequence
work. Otherwise show the problem. Safety Sequence if any < >

Rp2 = (0 0 2) <= Av OK, > Need P2 , then NO because request > need.

3.Can a request of R3 of (0 1 1) be granted for P3? If yes show safety sequence work.
Otherwise show the problem. Safety Sequence if any < 3 4 1 2 0 >

Rp3 = ( 0 1 1 ) <= Av OK, < = Need P3 OK, then


Alloc P3 = ( 2 2 2 ) and Need P3 = ( 0 0 0 ) and new available = ( 2 1 1 ).
Check for Safety:

433–5 3 5 - 5 3 6 - 8 3 8 - 9 5 8

2
Q3) First Exam Make-UP ( points)
I) Using Figures, and text, explain using different definitions what is an OS.

1. We can define OS’s as


 OS is a resource allocator:
 OS is a control program:
 OS is the intermediary between HW and Users.
Explain how these definitions fit into contemporary
operating systems requirements (user and system views)
 Manages all resources. Decides between
conflicting requests for efficient and fair
resource use

II) List the 5 basic OS managers:


1. Memory Manager
2. Process Manager
3. Network Manager
4. File Manager
5. DeviceManager
6. Print Manager
7. I/O Manager

III) Suppose the following jobs arrive for processing at the times indicated. Each job will run
the listed amount of time. What is the average Waiting-Time for these jobs if? Show
your work.
JOB Arrival Time CPU Burst Time1 IO Burst Time CPU Burst Time 2
1 0.0 8 2 8
2 1.0 4 2 4
3 2.0 1 2 1

1. First Come First Serve (FCFS)


1 2 3 1 2 3
8 12 13 21 25 26
WT1 = 0 - 0 + 13- 10 = 3
WT2 = 8 – 1 + 21- 14 = 14
WT3 = 13 - 2 + 25 – 15 = 21
2. Shortest Job First (Preemptive algorithm.)
1 2 3 2 3 2 1 2 1 idle 1
1 2 3 5 6 7 9 13 18 20 28

WT1 = 0 - 0 + 7 - 1 + 13 – 9 = 10
WT2 = 1 – 1 + 3-2 + 6-5 + 13 - 13 = 2
WT3 = 2 - 2 + 5- 5 = 0
IV) Now, if the start of execution is delayed until the last job has arrived (i.e. after job 3 in this
case), so the CPU is set idle (no processing) until the last job arrives. What will be the
average turnaround time for part 2 (SJF non-preemptive)? What is the CPU
Utilization? Show your work.
idle 3 2 3 1 2 1
2 3 7 8 16 20 28

ATA1 = 28-0 = 10 Ucpu = 26 /28


ATA2 = 20 – 1 = 19
ATA3 = 8 - 2 = 6

You might also like