Shortest Job First MCQ Quiz in मल्याळम - Objective Question with Answer for Shortest Job First - സൗജന്യ PDF ഡൗൺലോഡ് ചെയ്യുക
Last updated on Apr 3, 2025
Latest Shortest Job First MCQ Objective Questions
Top Shortest Job First MCQ Objective Questions
Shortest Job First Question 1:
On a system using non preemptive scheduling , process with expected runtime of 5, 18 , 9 ,12 are in ready queue . In what order they should be run to minimize wait time ?
Answer (Detailed Solution Below)
Shortest Job First Question 1 Detailed Solution
Shortest Job First (SJF) is an algorithm in which the process having the smallest execution time is chosen for the next execution. This scheduling method can be preemptive or non-preemptive. It significantly reduces the average waiting time for other processes awaiting execution. The full form of SJF is Shortest Job First.
The processes should execute in an SJF manner to get the lowest waiting time. If a process starts the execution the remaining process has to wait until it completes in a non-preemptive scheduling algorithm. So, the order should be 5, 9, 12, 18.
Hence the correct answer is 5, 9, 12, 18.
Shortest Job First Question 2:
Consider the following set of processes P1, P2, P3, P4, and P5 that need to be scheduled on a single CPU.
Process Name |
Arrival Time (in milliseconds) |
Execution Time (in milliseconds) |
P1 |
0 |
6 |
P2 |
3 |
2 |
P3 |
5 |
4 |
P4 |
7 |
6 |
P5 |
10 |
3 |
What is the difference between the average turnaround time and the average waiting time in milliseconds by using the shortest remaining time first scheduling algorithm?
Answer (Detailed Solution Below) 4.2
Shortest Job First Question 2 Detailed Solution
Scheduling Algorithm: Shortest Remaining Time First (Pre-emptive)
Gantt chart:
P1 |
P2 |
P1 |
P3 |
P5 |
P4 |
0 3 5 8 12 15 21
Formula:
Turnaround time = Completion time – Arrival time.
Process Table:
Process Name |
Arrival Time (AT) |
Execution Time (ET) |
Completion Time (CT) |
Turnaround time (TAT) |
Waiting time (WT) |
P1 |
0 |
6 |
8 |
8 |
2 |
P2 |
3 |
2 |
5 |
2 |
0 |
P3 |
5 |
4 |
12 |
7 |
3 |
P4 |
7 |
6 |
21 |
14 |
8 |
P5 |
10 |
3 |
15 |
5 |
2 |
Average turnaround time = \(\frac{{\left( {8\; + \;2\; + \;7\; + \;14\; + \;5} \right)}}{5} = 7.2\;msec\)
Average waiting time = \(\frac{{\left( {2\; + \;0\; + \;3\; + \;8\; + \;2} \right)}}{5} = 3\;msec\)
Difference = 7.2 - 3 = 4.2
Important Points:
TAT = CT - AT
WT = TAT - ET
Shortest Job First Question 3:
In which of the following scheduling criteria, context switching will never take place?
Answer (Detailed Solution Below)
Shortest Job First Question 3 Detailed Solution
Concept:
Transferring the control of CPU from one process to another demands saving the context of currently running process and loading the context of another ready process. This mechanism of saving and restoring the context is known as context switching.
Explanation:
Round robin scheduling:
It is pre-emptive scheduling algorithm which considers all the processes as equally important and treats them in favourable manner. Each process in ready queue gets a fixed amount of CPU time known as time quantum. If the process does not execute completely till end of time quantum, it is pre-empted and CPU is allocated to the next process in the ready queue. Context switching is needed in round robin scheduling.
Preemptive SJF:
It is also known as shortest remaining time first scheduling. Scheduler always chooses the process for execution that has the shortest remaining processing time. While a process is being executed, CPU can be taken back from it and can be assigned to some newly arrived process is burst of new process is shorter than its remaining burst time.
Non – preemptive SJF:
It is also known as shortest process next. In this, at any point of time among all the ready processes, the one having the shortest CPU burst time is scheduled first. There is no context switching in this algorithm.
Preemptive priority:
If the newly arrived process has the higher priority than the currently running process, the pre emptive priority scheduling algorithm pre-empts the currently running process and allocated CPU to the new process. It involves context switching.Shortest Job First Question 4:
Suppose that jobs arrive according to the following schedule :
Process | Arrival time | Run time |
A | 0 | 12 |
B | 3 | 7 |
C | 6 | 2 |
D | 8 | 5 |
E | 9 | 2 |
F | 12 | 12 |
Now give the sequence of the processes as they gets share of CPU if the scheduler used is Shortest Remaining Time First.
Answer (Detailed Solution Below)
Shortest Job First Question 4 Detailed Solution
Concept:
Shortest remaining time next: pre-emptive scheduling
In shortest remaining time next, when a process of less burst time(run time) arrives than in ready queue then context switch will happen
Explanation:
Time Running Remaining times at the end
0 – 3 A A – 9 B – 7
3 – 6 B A – 9 B – 4 C – 2
6 – 8 C A – 9 B – 4 D – 5
8 – 9 B A – 9 B – 3 D – 5 E – 2
9 – 11 E A – 9 B – 3 D – 5
11 – 12 B A – 9 B – 2 D – 5 F – 12
12 – 14 B A – 9 D – 5 F – 12
14 – 19 D A – 9 F – 12
19 – 28 A F – 12
28 – 40 FShortest Job First Question 5:
Consider the following four processes with arrival times (in milliseconds) and their lengths of CPU bursts (in milliseconds) as shown below :
Process |
P1 |
P2 |
P3 |
P4 |
Arrival time |
0 |
1 |
3 |
4 |
CPU burst time |
3 |
1 |
3 |
Z |
Answer (Detailed Solution Below)
Shortest Job First Question 5 Detailed Solution
The correct answer is 2
Explanation:
Assume that: P4 < P3
Gantt chart:
P1 |
P2 |
P1 |
P1 |
P4 | P3 |
0 1 2 3 4 4+Z 7+Z
Process Table1:
Process |
Arrival Time (AT) |
Burst Time (BT) |
Completion time (CT) |
Turnaround time TAT = CT - AT |
Waiting time WT = TAT - BT |
P1 |
0 |
3 |
4 |
4 |
1 |
P2 |
1 |
1 |
2 |
1 |
0 |
P3 |
3 |
3 |
7 + Z |
4 + Z |
1 + Z |
P4 |
4 |
z |
4 + Z |
Z |
0 |
Average waiting time = 1
\(\frac{{1 + 0 + \left( {1 + z} \right) + 0}}{4} = 1\)
The value of Z is 2.
Assume that: P4 ≥p3
Gantt chart:
P1 |
P2 |
P1 |
P1 |
P3 | P4 |
0 1 2 3 4 7 7+Z
Process Table2:
Process |
Arrival Time (AT) |
Burst Time (BT) |
Completion time (CT) |
Turnaround time TAT = CT - AT |
Waiting time WT = TAT - BT |
P1 |
0 |
3 |
4 |
4 |
1 |
P2 |
1 |
1 |
2 |
1 |
0 |
P3 |
3 |
3 |
7 |
4 |
1 |
P4 |
4 |
Z |
7 + Z |
Z + 3 |
3 |
Given average waiting time = 1
\(But\;\frac{{1 + 0 + 1 + 3}}{4} \ne 1\)
\(\frac{5}{{4}} \ne 1\)
\(∴ p4 > p3\;is\;not\;possible\;\)
∴ Z = 2
Shortest Job First Question 6:
Shortest job first scheduling algorithm uses _______ data structure and has ________ time complexity.
Answer (Detailed Solution Below)
Shortest Job First Question 6 Detailed Solution
Shortest job first scheduling algorithm uses min heap data structure for its implementation.
If there are n tasks and each task has to be inserted to the heap and later extracted from the heap, it results in a running time of O(nlogn).
Therefore, Shortest job first scheduling algorithm uses min heap data structure and has O(nlogn) time complexity.
Shortest Job First Question 7:
Shortest job first scheduling algorithm uses _______ data structure and has ________ time complexity.
Answer (Detailed Solution Below)
Shortest Job First Question 7 Detailed Solution
Shortest job first scheduling algorithm uses min heap data structure for its implementation.
If there are n tasks and each task has to be inserted to the heap and later extracted from the heap, it results in a running time of O(nlogn).
Therefore, Shortest job first scheduling algorithm uses min heap data structure and has O(nlogn) time complexity.
Shortest Job First Question 8:
Which of the following approaches was utilized to allocate CPU time among various processes?
Answer (Detailed Solution Below)
Shortest Job First Question 8 Detailed Solution
The correct answer is Processor Management.
Key Points
- Processor Management is the function of an operating system that allocates CPU time to various processes.
- This ensures that all active processes receive a fair share of the CPU's processing power.
- The operating system uses scheduling algorithms to determine the order in which processes are given CPU time.
- Common scheduling algorithms include First-Come, First-Served (FCFS), Shortest Job Next (SJN), and Round Robin (RR).
- Processor management also involves managing process states and transitions, such as from running to waiting, or from waiting to ready.
- Proper processor management ensures efficient CPU usage, responsiveness, and system stability.
Additional Information
- Processor management is a critical component of multitasking operating systems, allowing multiple processes to run concurrently.
- It helps in prioritizing processes, so that important tasks receive more CPU time compared to less critical ones.
- Advanced processor management techniques include multi-core processing and parallel processing, which further enhance system performance.
- Historically, early operating systems had simpler processor management techniques, but modern systems use complex algorithms to improve efficiency.
Shortest Job First Question 9:
Consider the following three processes with the arrival time and CPU burst time given in
milliseconds:
Process |
Arrival Time |
Burst Time |
P1 |
0 |
7 |
P2 |
1 |
4 |
P3 |
2 |
8 |
The Gantt Chart for preemptive SJF scheduling algorithm is
Answer (Detailed Solution Below)
Shortest Job First Question 9 Detailed Solution
Concepts:
Shortest remaining time first (SRTF), is a scheduling method that is a pre-emptive version of shortest job first (SJF).
In this scheduling algorithm, the process with the smallest amount of time remaining until completion is selected to execute.
Explanation:
At t = 0:
Only Process P1 is available and hence P1 is executed for 1 ms.
At t = 1:
Process P1 and Process P2 are available, between them P2 has least burst time. Therefore, P1 gets pre-empted and hence P2 is executed for 1 ms.
At t = 2:
All three process are available. Since P2 is having least burst time it executes till its completion followed by Process P1 and process P3 respectively
Gantt chart:
Preemptive SJF scheduling is equal to SRTF
Shortest Job First Question 10:
In which of the following scheduling criteria, context switching will never take place?
Answer (Detailed Solution Below)
Shortest Job First Question 10 Detailed Solution
Concept:
Transferring the control of CPU from one process to another demands saving the context of currently running process and loading the context of another ready process. This mechanism of saving and restoring the context is known as context switching.
Explanation:
Round robin scheduling:
It is pre-emptive scheduling algorithm which considers all the processes as equally important and treats them in favourable manner. Each process in ready queue gets a fixed amount of CPU time known as time quantum. If the process does not execute completely till end of time quantum, it is pre-empted and CPU is allocated to the next process in the ready queue. Context switching is needed in round robin scheduling.
Preemptive SJF:
It is also known as shortest remaining time first scheduling. Scheduler always chooses the process for execution that has the shortest remaining processing time. While a process is being executed, CPU can be taken back from it and can be assigned to some newly arrived process is burst of new process is shorter than its remaining burst time.
Non – preemptive SJF:
It is also known as shortest process next. In this, at any point of time among all the ready processes, the one having the shortest CPU burst time is scheduled first. There is no context switching in this algorithm.
Preemptive priority:
If the newly arrived process has the higher priority than the currently running process, the pre emptive priority scheduling algorithm pre-empts the currently running process and allocated CPU to the new process. It involves context switching.