Process-Scheduling
Question 1 |
Consider the following set of processes, assumed to have arrived at time 0. Consider the CPU scheduling algorithms Shortest Job First (SJF) and Round Robin (RR). For RR, assume that the processes are scheduled in the order P1,P2,P3,P4.
If the time quantum for RR is 4 ms, then the absolute value of the difference between the average turnaround times (in ms) of SJF and RR (round off to 2 decimal places) is _____.
5.25 |
Turn Around Time = (21 – 0) + (13 – 0) + (2 – 0) + (6 – 0), Average = 42/4 = 10.50
Turn Around Time (TAT) = (18 – 0) + (21 – 0) + (10 – 0) + (14 – 0), Average = 63/4 = 15.75
Absolute difference = |10.50-15.75| = 5.25
Question 2 |
Consider the following statements about process state transitions for a system using preemptive scheduling.
- I. A running process can move to ready state.
II. A ready process can move to running state.
III. A blocked process can move to running state.
IV. A blocked process can move to ready state.
Which of the above statements are TRUE?
II and III only | |
I, II and III only
| |
I, II, III and IV
| |
I, II and IV only
|
Question 3 |
Consider the 3 processes, P1, P2 and P3 shown in the table.
Process Arrival time Time Units Required P1 0 5 P2 1 7 P3 3 4
The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are
FCFS: P1, P2, P3 RR2: P1, P2, P3 | |
FCFS: P1, P3, P2 RR2: P1, P3, P2 | |
FCFS: P1, P2, P3 RR2: P1, P3, P2 | |
FCFS: P1, P3, P2 RR2: P1, P2, P3 |
FCFS is clear.
RR Queue: In RR queue time slot is of 2 units.
Processes are assigned in following order
P1, P2, P1, P3, P2, P1, P3, P2, P2
This question used the ready queue concept. At t=2, P2 starts and P1 is sent to the ready queue and at t=3 P3 arrives so then the job P3 is queued in the ready queue after P1. So at t=4, again P1 is executed then P3 is executed for the first time at t=6.
RR2: P1, P3, P2
So option C.
Question 4 |
Four jobs to be executed on a single processor system arrive at time 0+ in the order A, B, C, D. their burst CPU time requirements are 4, 1, 8, 1 time units respectively. The completion time of A under round robin scheduling with time slice of one time unit is
10 | |
4 | |
8 | |
9 |
∴ Completion time of A is 9 unit.
Question 5 |
The process state transition diagram in below figure is representative of
a batch operating system | |
an operating system with a preemptive scheduler | |
an operating system with a non-preemptive scheduler | |
a uni-programmed operating system |
So this is preemptive.
Question 6 |
Consider n processes sharing the CPU in a round-robin fashion. Assuming that each process switch takes s seconds, what must be the quantum size q such that the overhead resulting from process switching is minimized but at the same time each process is guaranteed to get its turn at the CPU at least every t seconds?
q ≤ t-ns/n-1 | |
q ≥ t-ns/n-1 | |
q ≤ t-ns/n+1 | |
q ≥ t-ns/n+1 |
Question 7 |
Consider a set of n tasks with known runtimes r1, r2, ..., rn to be run on a uniprocessor machine. Which of the following processor scheduling algorithms will result in the maximum throughput?
Round-Robin | |
Shortest-Job-First | |
Highest-Response-Ratio-Next | |
First-Come-First-Served |
Question 8 |
Which of the following scheduling algorithms is non-preemptive?
Round Robin | |
First-In First-Out | |
Multilevel Queue Scheduling | |
Multilevel Queue Scheduling with Feedback |
Question 9 |
A uni-processor computer system only has two processes, both of which alternate 10ms CPU bursts with 90ms I/O bursts. Both the processes were created at nearly the same time. The I/O of both processes can proceed in parallel. Which of the following scheduling strategies will result in the least CPU utilization (over a long period of time) for this system?
First come first served scheduling | |
Shortest remaining time first scheduling | |
Static priority scheduling with different priorities for the two processes | |
Round robin scheduling with a time quantum of 5 ms
|
(i) FCFS:
0-10: Process 1 can execute
10-20: Process 2 can execute
100-110: Process 1 Terminate
110-120: Process 2 Terminate
CPU utilization = 20/100 [In every 100ms it utilizes]
=20%
(ii) SRTF: can process P and Q same as FCFS
then CPU utilization = 20%
(iii) Round robin: with TQ-5
0-5: Process P1
5-10: Process P2
10-15: Process P1
15-20: Process P2
105-110: Process P1
110-115: Process P2
CPU utilization = 20/105 = 19.5
Question 10 |
The arrival time, priority, and duration of the CPU and I/O bursts for each of three processes P1, P2 and P3 are given in the table below. Each process has a CPU burst followed by an I/O burst followed by another CPU burst. Assume that each process has its own I/O resource.
The multi-programmed operating system uses preemptive priority scheduling. What are the finish times of the processes P1, P2 and P3 ?
11, 15, 9 | |
10, 15, 9 | |
11, 16, 10 | |
12, 17, 11 |
Hence, finish times of process.
P1 - 10
P2 - 11
P3 - 9
Question 11 |
The process state transition diagram of an operating system is as given below.
Which of the following must be FALSE about the above operating system?
It is a multiprogrammed operating system | |
It uses preemptive scheduling | |
It uses non-preemptive scheduling | |
It is a multi-user operating system |
Question 12 |
Consider n jobs J1, J2,......Jn such that job Ji has execution time ti and a non-negative integer weight wi. The weighted mean completion time of the jobs is defined to be , where Ti is the completion time of job Ji. Assuming that there is only one processor available, in what order must the jobs be executed in order to minimize the weighted mean completion time of the jobs?
Non-decreasing order of ti | |
Non-increasing order of wi | |
Non-increasing order of witi | |
None-increasing order of wi/ti |
So answer is the non-increasing order of wi/ti.
Question 13 |
Let a memory have four free blocks of sizes 4k, 8k, 20k, 2k. These blocks are allocated following the best-fit strategy. The allocation requests are stored in a queue as shown below.
The time at which the request for J7 will be completed will be
16 | |
19 | |
20 | |
37 |
At t = 8
At t = 10
At t = 11
J7 can be finished at t = 19.
Question 14 |
Consider the following set of processes, with the arrival times and the CPU-burst times given in milliseconds.
Process Arrival Time Burst Time P1 0 5 P2 1 3 P3 2 3 P4 4 1
What is the average turnaround time for these processes with the preemptive shortest remaining processing time first (SRPT) algorithm?
5.50 | |
5.75 | |
6.00 | |
6.25 |
Avg. TAT = 12+3+6+1/4 = 22/4 = 5.50
Question 15 |
Consider a uniprocessor system executing three tasks T1, T2 and T3, each of which is composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 3, 7 and 20 milliseconds, respectively. The priority of each task is the inverse of its period and the available tasks are scheduled in order of priority, with the highest priority task scheduled first. Each instance of T1, T2 and T3 requires an execution time of 1, 2 and 4 milliseconds, respectively. Given that all tasks initially arrive at the beginning of the 1st millisecond and task preemptions are allowed, the first instance of T3 completes its execution at the end of ______________ milliseconds.
13 | |
12 | |
15 | |
16 |
∴ At the end of 12 milliseconds, 1st instance of T3 will complete its execution.
Question 16 |
Consider the following processes, with the arrival time and the length of the CPU burst given in milliseconds. The scheduling algorithm used is preemptive shortest remaining-time first.
The average turn around time of these processes is _________ milliseconds.
8.25 | |
8.26 | |
8.27 | |
8.28 |
To answer the question we need to design the gantt chart:
In this algorithm, the processes will be scheduled on the CPU which will be having least remaining burst time.
Turnaround Time (TAT) = Completion Time (CT) - Arrival Time (AT)
TAT for P1 = 20 - 0 = 20,
TAT for P2 = 10 - 3 = 7,
TAT for P3 = 8 - 7 = 1,
TAT for P4 = 13 - 8 = 5.
Total TAT = 20 + 7 + 1 + 5 = 33 / 4 = 8.25 (Avg. TAT)
Question 17 |
Consider an arbitrary set of CPU-bound processes with unequal CPU burst lengths submitted at the same time to a computer system. Which one of the following process scheduling algorithms would minimize the average waiting time in the ready queue?
Shortest remaining time first | |
Round-robin with time quantum less than the shortest CPU burst | |
Uniform random | |
Highest priority first with priority proportional to CPU burst length |
We can consider an arbitrary set of CPU-bound processes with unequal CPU burst lengths submitted at the same time to a computer system.
We have to choose the appropriate process scheduling algorithms, which would minimize the average waiting time in the ready queue.
Waiting time is the time for which process is ready to run but not executed by CPU scheduler.
In all CPU Scheduling algorithms, shortest job first is optimal.
It gives minimum turnaround time, minimum average waiting time and high throughput and the most important thing is that shortest remaining time first is the preemptive version of shortest job first.
This scheduling algorithm may lead to starvation because if the short processes are added to the CPU scheduler continuously then the currently running process will never be able to execute as they will get pre-empted but here all the processes are arrived at same time so there will be no issue such as starvation.
SRTF would be same as SJF.
So, A is the answer. Shortest remaining time first.
Question 18 |
Consider the set of processes with arrival time (in milliseconds), CPU burst time (in milliseconds), and priority (0 is the highest priority) shown below. None of the processes have I/O burst time.
The average waiting time (in milliseconds) of all the processes using preemptive priority scheduling algorithm is __________.
29 | |
30 | |
31 | |
32 |
Waiting Time = 0 + (33 - 5) + (40 - 2) + (49 - 12) + (51 - 9) = 145
Average waiting time: 145/5 = 29
Question 19 |
Consider the following CPU processes with arrival times (in milliseconds) and length of CPU bursts (in milliseconds) as given below:
If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes, then the average waiting time across all processes is __________ milliseconds.
3 | |
4 | |
5 | |
6 |
Question 20 |
Consider the following four processes with arrival times (in milliseconds) and their length of CPU bursts (in milliseconds) as shown below:
These processes are run on a single processor using preemptive Shortest Remaining Time First scheduling algorithm. If the average waiting time of the processes is 1 millisecond, then the value of Z is _____.
2 | |
7 | |
1 | |
4 |
At this point P4 arrives with burst 'Z' & P3 is in queue with burst 3.
P1 & P2 have executed with P1 incurred delay 1unit & P2 0units.
Hence, Avg = 0+1+x/4 =1
⇒ x=3, the next delay should be 3. It would happen if assume Z=2.
It executes and completes at 6.
P3 will wait totally for 3units.
Hence, Avg=1.
Z=2
Question 21 |
For the processes listed in the following table, which of the following scheduling schemes will give the lowest average turnaround time?
First Come First Serve | |
Non-preemptive Shortest Job First | |
Shortest Remaining Time | |
Round Robin with Quantum value two |
FCFS:
TAT for A = completion time(A) - AT(A) = 3 - 0 = 3
TAT of B = 9 - 1 = 8
TAT of C = 13 - 4 = 9
TAT of D = 15 - 6 = 9
∴ Avg. TAT = 29/4
SJF:
TAT of A = 3 - 0 = 3
TAT of B = 9 - 1 = 8
TAT of C = 15 - 4 = 11
TAT of D = 11 - 6 = 5
∴ Avg. TAT = 27/4
SRTF:
TAT of A = 3 - 0 = 3
TAT of B = 15 - 1 = 14
TAT of C = 8 - 4 = 4
TAT of D = 10 - 6 = 4
∴ Avg. TAT = 25/4
RR:
TAT of A = 5 - 0 = 5
TAT of B = 15 - 1 = 14
TAT of C = 13 - 4 = 9
TAT of D = 11 - 6 = 5
∴ Avg. TAT = 33/4
∴ SRTF has lowest Avg. TAT.
Question 22 |
The maximum number of processes that can be in Ready state for a computer system with n CPUs is
n | |
n2 | |
2n | |
Independent of n |
Maximum number of processes that will be in ready state is independent of number of processors.