Solutions - Concordia University

Department of Electrical and Computer Engineering
Concordia University
Operating Systems - COEN 346
Winter 2017
Inst.: Ferhat Khendek
Assignment #3 – Solutions
Total points: 100
Question 1. [10 points]
Consider the following preemptive priority-scheduling algorithm based on dynamically
changing priorities. Larger priority numbers imply higher priority. When a process is
waiting for the CPU, i.e. ready but not running, its priority changes at a rate ; when it is
running, its priority changes at a rate . All processes are given a priority of 0 when they
enter the ready queue. The parameters  and  can be set to give many different scheduling
algorithms.
a. What is the algorithm that results from  >  > 0?
b. What is the algorithm that results from  <  < 0?
Explain
Answer.
a. Very close to First Come First Served. [5 points]
b. Last in First out. [5 points]
Question 2. Exercise #6.15 Page 308 in Textbook [10 points]
Answer.
This scheduler would favor CPU-bound processes as they are rewarded with a longer time
quantum as well as priority boost whenever they consume an entire time quantum. This
scheduler does not penalize I/O bound processes as they are likely to block for I/O before
consuming their entire time quantum, but their priority remains the same.
Question 3. Exercise #6.17 Page 308 in Textbook [15 points]
Answer.
a. Provide your Gant Charts [5 points]
b. P1: 20-0 = 20, P2: 80-25 = 55, P3: 90 - 30 = 60, P4: 75-60 = 15, P5: 120-100 = 20,
P6: 115-105 = 10 [3 points]
c. P1: 0, P2: 40, P3: 35, P4: 0, P5: 10, P6: 0 [This is the total each process will spent
in the ready queue until it finishes execution of the burst. Note you can also
determine the waiting time as the time a process waits in the ready queue before
getting the CPU for the first time only.] [4 points]
d. 105/120 = 87.5 percent. [3 points]
1
Question 4. Exercise #6.19 Page 309 in Textbook [10 points]
Answer.
Shortest job first and priority-based scheduling algorithms could result in starvation.
Question 5. Exercise #6.20 Page 309 in Textbook [10 points]
Answer.
a. In effect, that process will have increased its priority since by getting time more
often it is receiving preferential treatment. [3 points]
b. The advantage is that more important jobs could be given more time, in other
words, higher priority in treatment. The consequence, of course, is that shorter jobs
will suffer. [3 points]
c. Allot a longer amount of time to processes deserving higher priority. In other words,
have two or more quantums possible in the Round-Robin scheme. [4 points]
Question 6. Exercise #6.31 Page 311 in Textbook [10 points]
Answer.
Consider when P1 is assigned a higher priority than P2 with the rate monotonic scheduler.
P1 is scheduled at t = 0, P2 is scheduled at t = 25, P1 is scheduled at t = 50, and P2 is
scheduled at t = 75. P2 is not scheduled early enough to meet its deadline. When P1 is
assigned a lower priority than P2, then P1 does not meet its deadline since it will not be
scheduled in time.
Question 7. Exercise #7.17 Page 343 in Textbook [10 points]
Answer.
Suppose the system is deadlocked. This implies that each process is holding one resource
and is waiting for one more. Since there are three processes and four resources, one process
must be able to obtain two resources. This process requires no more resources and,
therefore it will return its resources when done.
Question 8. Exercise #7.19 Page 343 in Textbook [10 points]
Answer.
The following rule prevents deadlock: when a philosopher makes a request for the first
chopstick, do not grant the request if there is no other philosopher with two chopsticks and
if there is only one chopstick remaining.
2
Question 9. Exercise #7.23 Page 343 in Textbook [15 points]
Answer.
a. It is a safe state. The following sequence of resource allocation is possible: P0, P3,
P1, P2, P4
b. Yes it can be granted as the system will move to a safe state after granting this
request. The state is safe because the following sequence of allocation is possible:
P0, P3, P1, P2, P4.
c. No, if we do so we get into a deadlock state actually, worse than an unsafe state.
3