Skip to content
Official PYQ · 1998

GATE CS 1998 Q7-b — CPU Scheduling

Explain with AI
In a computer system where the ‘best-fit’ algorithm is used for allocating ‘jobs’ to ‘memory partitions’, the following situation was encountered:Partitions size in KB4K 8K 20K 2KJob sizes in KB2K 14K 3K 6K 6K 10K 20K 2KTime for execution4 10 2 1 4 1 8 6\begin{array}{|l|l|} \hline \textbf{Partitions size in $KB$} & \textbf{$4K \ 8K \ 20K \ 2K$} \\ \hline \textbf{Job sizes in $KB$} & \text{$2K \ 14K \ 3K \ 6K \ 6K \ 10K \ 20K \ 2K$} \\ \hline \textbf{Time for execution} & \text{$4 \ 10 \ 2 \ 1 \ 4 \ 1 \ 8 \ 6$} \\ \hline \end{array}When will the 20K20K job complete?
View worked solution

Answer: 19

We trace the allocation of jobs to memory partitions using the Best-Fit algorithm and a strict FIFO queue order.

Initial State (t=0t = 0):

  • Partitions: P1(4K)P_1(4K), P2(8K)P_2(8K), P3(20K)P_3(20K), P4(2K)P_4(2K) (all free).
  • Jobs are allocated as follows:
    • J1(2K)J_1(2K) allocated to P4(2K)P_4(2K) [best-fit]. Runs t=0→4t = 0 \to 4.
    • J2(14K)J_2(14K) allocated to P3(20K)P_3(20K) [best-fit]. Runs t=0→10t = 0 \to 10.
    • J3(3K)J_3(3K) allocated to P1(4K)P_1(4K) [best-fit]. Runs t=0→2t = 0 \to 2.
    • J4(6K)J_4(6K) allocated to P2(8K)P_2(8K) [best-fit]. Runs t=0→1t = 0 \to 1.

Timeline of events:

  • At t=1t = 1: J4J_4 completes. P2(8K)P_2(8K) becomes free. Next job J5(6K)J_5(6K) is allocated to P2(8K)P_2(8K). Runs t=1→5t = 1 \to 5.
  • At t=2t = 2: J3J_3 completes. P1(4K)P_1(4K) becomes free. Next job J6(10K)J_6(10K) cannot fit in any free partition (P1P_1 is free). The queue is blocked.
  • At t=4t = 4: J1J_1 completes. P4(2K)P_4(2K) becomes free. J6(10K)J_6(10K) still cannot fit.
  • At t=5t = 5: J5J_5 completes. P2(8K)P_2(8K) becomes free. J6(10K)J_6(10K) still cannot fit.
  • At t=10t = 10: J2J_2 completes. P3(20K)P_3(20K) becomes free. J6(10K)J_6(10K) is allocated to P3(20K)P_3(20K) [best-fit]. Runs t=10→11t = 10 \to 11. Next job J7(20K)J_7(20K) must wait.
  • At t=11t = 11: J6J_6 completes. P3(20K)P_3(20K) becomes free. J7(20K)J_7(20K) is allocated to P3(20K)P_3(20K) [best-fit]. Runs t=11→19t = 11 \to 19.

Thus, the 20K20K job (J7J_7) completes at time 19.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore CPU Scheduling questions