Professional Documents
Culture Documents
Operating systems provide the classic application domain for certain techniques that are useful in
other contexts. For example resource allocation; Security; and fault tolerance are all topics that are
traditionally thought of as “operating system” topics that now have broad applicability
c. Real Time Systems: the system reads information from sensors and must respond within
a fixed amount of time to ensure correct performance
P18PSCS8037
another job until the kernel signals to the thread that the I/O operation is complete. It
then interrupts its current job and process the data from the I/O operation.
e) State three things you like and two that you do not like about this course
Three (3) Likes
It is a practical course. The user gets to operate the system due to user friendly
interface
It provides for convenient usage of the system such as memory management.
Without the operating system, the user and hardware as components of the
operating system cannot function.
b) Show how TestAndSet can be used to solve the critical section problem Boolean
TestAndSet(boolean *target) {
boolean rv = *target;
*target = TRUE;
return rv;
}
P18PSCS8037
Solution
do {
while (TestAndSetLock(&Lock))
// do nothing
// Critical section
Lock = FALSE;
// remainder section
} while (TRUE);
b) Consider the following set of processes, with the length of the CPU-burst time given in
milliseconds
Process Burst Time Priority
P1 10 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2
i. Draw Gantt Charts illustrating the execution of these processes using a non-preemptive priority
(a smaller priority number implies a higher priority), and Round Robin (quantum = 1) scheduling.
Non-pre-emptive priority
P2 P5 P1 P3 P4
a. 1 6 16 18 19
9 0 1 0 4 8 0 3 7 2 6 1 5 0 4 3 2 1 0
P1 P2 P3 P4 P5 P1 P3 P5 P1 P5 P1 P5 P1 P5 P1 P1 P1 P1 P1
b. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
ii. What is the average turnaround time of each process for each of the scheduling
algorithm in i?
The Average turnaround time for Non-pre-emptive priority
P2= 1; P5= 6; P1= 16; P3= 18; P4= 19
P18PSCS8037
The Average turnaround time for Round Robbin (Quantum = 1)
P1= 19; P2= 2; P3= 7; P4= 4; P5= 14
c) Suppose that the same processes arrive for execution at the times indicated below but with the
same burst time as given in b) above.
Process Burst Time Arrival Time
P1 10 0.0
P2 1 0.5
P3 2 1.0
P4 1 1.2
P5 5 1.5
i. Draw Gantt Charts illustrating the execution of these processes using FCFS and SJF
non-preemptive scheduling
ii. Which of the schedules in i) results in the minimal average waiting time (over all
processes)?
P1= 0; P2= 10-0.5= 9.5; P3= 11-1.0= 10; P4= 13-1.2= 11.8; P5= 14-1.5= 12.5
P1= 0; P2= 10-0.5= 9.5; P3= 12-1= 11; P4= 11-1.2= 9.8; P5= 14-1.5= 12.5
Shortest Job First has the minimal average waiting time with average waiting time of 8.56
milliseconds.
P18PSCS8037