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: Burst Time Arrival CPU burst 1 I/O burst 1 CPU burst 2 I/O burst 2 CPU burst 3 Time 1 2 4 2 2 2 0 2 2 2 3 3 1 1 3 1 2 1 1 1 1 We make the following two assumptions:
Disk queue Ready queue 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 is running (executing) is ready is waiting is doing I/O has terminated Also show the processes on the ready queue and disk queue. 1. Shortest Job First (SJF) algorithm Time 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 (head ) (head )
Disk queue Ready queue 2. Round robin (RR) algorithm with time quantum = 1 Time 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 (head) (head) Part B: What is the waiting time of each process for each of the above scheduling algorithms? What is the average waiting time? Average SJF Wait time RR (q=1) Part C: What is the turnaround time of each process for each of the above scheduling algorithms? What is the average turnaround time? Average SJF Turnaround time RR (q=1)
Question 2 Consider two user processes and in a uniprocessor system. has two threads. has three threads. The CPU burst times for the threads are shown in the table below: Thread CPU burst time T11 T12 1 3 T21 T22 T23 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: and In:T11andT12 In:T21andT22andT23 Draw a Gantt chart that illustrates the execution of these threads. Time 0 1 2 3 4 5 6 7 8 9