King Saud University College of Computer & Information Sciences Information Technology Department IT425: Operating Systems Assignment 6 Second Semester 1433/1434H – 2012/2013 Homework policy: 1) Copying any part of other people's solutions or from any other sources is strictly prohibited. 2) If your source is the web, write your references in details. 3) Solutions quality (understandable and organized document, not handwriting). 4) Always start doing your assignment EARLY. Waiting until the last few hours is definitely not a wise move. ------------------------------------------------------------------------------------------------------------------------------------ Question 1. Consider a system with a single processor. The system has a single disk that is available SJF to only one process at any given time non-preemptively(i.e., if one process is accessing the disk, the other process has to wait for that process to finish using the disk before it can access it). Suppose that the following three processes arrive at the times indicated in the table below. Each process makes a CPU burst, then an I/O burst to access the disk, another CPU burst, another I/O burst to access the disk and finally terminates with a CPU burst. The lengths of these bursts are given in milliseconds in the table below: Process 1 2 3 CPU burst 1 2 2 1 Burst Time I/O burst 1 CPU burst 2 4 2 2 3 2 1 We make the following two assumptions: I/O burst 2 2 3 1 CPU burst 3 2 1 1 Arrival Time 0 1 1 1. If a new process arrives at the same time that a process finishes using the CPU, then the new process will be added to the ready queue first. 2. If an I/O completion and a CPU timeout of two processes occur at the same time, the process completing I/O is added to the ready queue first. Part A.Fill in the three Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: 1. Shortest Job First (SJF) algorithm 2. Round robin (RR) algorithm with quantum = 1 On each Gantt chart, use the following symbols to indicate the state of the process: Symbol x r w i t State Process is running (executing) Process is ready Process is waiting Process is doing I/O Process has terminated Also show the processes on the ready queue and disk queue. Disk queue Ready queue Process 1. Shortest Job First (SJF) algorithm Time P1 P2 P3 Pid (head ) Pid Pid (tail) Pid (head ) Pid Pid (tail) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 13 14 15 16 17 18 19 20 Disk queue Ready queue Process 2. Round robin (RR) algorithm with time quantum = 1 0 1 2 3 4 5 6 7 8 9 10 11 12 Time P1 P2 P3 Pid (head) Pid Pid (tail) Pid (head) Pid Pid (tail) Part B: What is the waiting time of each process for each of the above scheduling algorithms? What is the average waiting time? Process Wait time SJF RR (q=1) P1 P2 P3 Average Part C: What is the turnaround time of each process for each of the above scheduling algorithms? What is the average turnaround time? Process P1 P2 P3 Average Turnaround time SJF RR (q=1) 21 Question 2 Consider two user processes P1 and P2 in a uniprocessor system. P1 has two threads. P2 has three threads. The CPU burst times for the threads are shown in the table below: Process P1 P2 Thread T11 T12 T21 T22 T23 CPU burst time 1 3 3 2 1 In the following questions, assume the context switch time to be zero. a)Suppose the one-to-one model is being used to map the user threads to the kernel threads. The scheduling algorithm being used by the kernel is Round Robin with time quantum = 1 ms. The ready queue at time 0 is as follows: T22 T11 T23 T12 T21 where T21 is at the head of the queue. Draw a Gantt chart that illustrates the execution of these threads. Time 0 1 2 3 4 5 6 7 8 9 b)Suppose the threads are implemented entirely at the user level. A many-to-one model is used for mapping the user threads to the underlying kernel thread for the process. The scheduling algorithm used for the kernel threads is Round Robin with a time quantum of 2 ms.The scheduling algorithm for the user threads is Round Robin with a time quantum of 1 ms. Suppose the processes are moved to the ready state in the following order: P1andP2 InP1:T11andT12 InP2:T21andT22andT23 Draw a Gantt chart that illustrates the execution of these threads. Time 0 1 2 3 4 5 6 7 8 9