Assignment 5 - Operating System

advertisement
King Saud University
College of Computer & Information Sciences
Information Technology Department
IT325: Operating Systems
Assignment 5
Summer Semester 1433/1434H – 2012/2013
------------------------------------------------------------------------------------------------------------------------------------
Question 1: Suppose the following jobs are to be executed in a uniprocessor system.
Process Number
P1
P2
P3
P4
P5
Arrival time
0
2
5
10
12
Burst time
6
8
2
5
4
Priority
3
1
2
4
3
Assume 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. For each of the following Scheduling
algorithms, give:
(i) A Gantt chart to illustrate the execution sequence,
(ii) The average turnaround time. Only FCFS, SRTF and RR
(iii) The average waiting time. Only FCFS, SRTF and RR
a. FCFS
b. SJF
c. SRTF
d. Preemptive priority
e. Non-preemptive priority
f. RR (quantum =3)
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
T13
T21
T22
CPU burst time
3
2
1
1
3
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 = 2 ms. The
ready queue at time 0 is as follows:
T12 T21 T13 T22 T11
where T11 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) 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 Shortest Job First.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: T11andT12andT13
InP2: T21andT22
Draw a Gantt chart that illustrates the execution of these threads.
Time
0
1
2
3
4
5
6
7
8
9
Download