Second (3)
Second (3)
Second (3)
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)
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:
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 >
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.
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
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