Question
Process Burst Time Priority Arrival Time P1 8 2 0 P2 5 3 6 P3 1 1 8 P4 2 5 9 P5 6 4
Process | Burst Time | Priority | Arrival Time |
P1 | 8 | 2 | 0 |
P2 | 5 | 3 | 6 |
P3 | 1 | 1 | 8 |
P4 | 2 | 5 | 9 |
P5 | 6 | 4 | 10 |
Problem1 (40 pts)
Consider the following set of processes, with the length of the CPU burst times given in milliseconds:
-
Draw four Gantt charts illustrating the execution of the processes using FCFS, Preemptive SJF, a non-preemptive priority, and a RR (quantum=2) scheduling. (30 pts)
Note: for the RR consider that the arriving time is 0 for all processes
-
What is the average waiting time of each process for of the above scheduling algorithms? (10 pts)
P1 | P2 | P3 | P4 | P5 | Average | |
FCFS | ||||||
SJF | ||||||
Priority | ||||||
RR |
Problem2 (40 pts)
Given 3 concurrent processes P1, P2 and P3, we suppose that initially the shared variable x =4.
-
List all the possible values for x. (15 pts)
-
Use one or more semaphores (use primitives signal and wait) in order to get x=13. ( 15 pts)
-
Can we use only one semaphore to get x=11? Explain your answer. (10 pts)
P1 | P2 | P3 |
; x++;
|
x =x-2; . |
x=x*3;
|
Problem3 (20 pts)
In the Dining-Philosophers Problem explained in the class, one possible solution to avoid the deadlock problem is to use an asymmetric solution (An odd philosopher picks up first her left chopsticks and even philosopher picks up her right chopstick and then right).
Describe this solution using a pseudo-code algorithm assuming that a variable x represent a philosophers position (x can range from 0 to 4).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started