Homework #3 Solution

$30.00

Category:

Description

4 Marks) Question 1. List and describe the necessary conditions for deadlock.

 

 

(3 Marks) Question 2. Show how the following pseudo code could be modified to avoid deadlock.

 

Explain your answer.

 

Shared Variables:  lockA, lockB, resourceA, resourceB

 

 

Process1 {

 

aquire(lockA);

aquire(lockB);

modify(resourceA);

 

modify(resourceB);

 

release(lockB);

release(lockA);
Process2 {

 

aquire(lockB);

aquire(lockA);

modify(resourceB);

 

modify(resourceA);

 

release(lockA);

release(lockB);

 

 

}
}

 

 

 

(3 marks) Question 3. Explain how quantum value and the time taken to perform a context switch affect each other in a round robin process-scheduling algorithm.

 

(6 Marks) Question 4. If a hard real-time system has four tasks with periods of 50, 100, 200, and 250 ms (milliseconds) respectively, and the four tasks require 35, 20, 10, and X ms of CPU time respectively, calculate the largest value of X for which the system is schedulable and state the scheduling algorithm used. Show all your work and include charts if you feel they will make your answer clearer.

 

 

(9 marks) Question 5. Five threads, A through E, arrive in alphabetic order at a scheduling queue one second apart from each other. Estimated running times are 10, 6, 2, 4, and 8 seconds, respectively. Their externally determined priorities are 3, 5, 2, 1, and 4, respectively, 5 being the highest priority. For each of the following scheduling algorithms, determine the mean turnaround time and mean waiting time. Assume thread switching is effectively instantaneous.

 

  • First Come First Served

 

  • Round Robin
  • Preemptive Priority Scheduling
  • Preemptive Shortest Job First

 

For (b), assume the system is multi-programmed with a quantum of 4 seconds. In all cases, show your work and include diagrams/charts/tables as appropriate.

 

UCSC BSOE CMPS111 Winter 2018                                                                           Copyright © 2017-2018 David C. Harrison. All Rights reserved.

 


error: Content is protected !!