GATE 2006
191 questions
MCQ 1911-mark 191
Questions 151–155 of 191
The arrival time, priority, and duration of the CPU and I/O bursts for each of three processes and 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 and ?
The multi-programmed operating system uses preemptive priority scheduling. What are the finish times of the processes and ?
Answer: (B)
Priorities: is highest (1), is next (2), is lowest (3). Each process has its own I/O device, so I/O never waits for another process.
I/O of the three processes:
- 0 to 1: runs its first CPU burst. Then its I/O runs from 1 to 6.
- 2 to 3: arrives and runs (1 of 3 units done).
- 3 to 5: arrives with higher priority and pre-empts . It runs its 2 units. Its I/O runs from 5 to 8.
- 5 to 6: the CPU goes back to (2 of 3 units done).
- 6 to 8: returns from I/O, pre-empts and runs 2 of its 3 units.
- 8 to 9: returns from I/O and pre-empts . It runs its last unit and finishes at 9.
- 9 to 10: runs its last unit and finishes at 10.
- 10 to 11: finishes its CPU burst. Then its I/O runs from 11 to 14.
- 14 to 15: runs its last CPU unit and finishes at 15.
So the finish times of are 10, 15 and 9.
Answer: (B)
I/O of the three processes:
- 0 to 1: runs its first CPU burst. Then its I/O runs from 1 to 6.
- 2 to 3: arrives and runs (1 of 3 units done).
- 3 to 5: arrives with higher priority and pre-empts . It runs its 2 units. Its I/O runs from 5 to 8.
- 5 to 6: the CPU goes back to (2 of 3 units done).
- 6 to 8: returns from I/O, pre-empts and runs 2 of its 3 units.
- 8 to 9: returns from I/O and pre-empts . It runs its last unit and finishes at 9.
- 9 to 10: runs its last unit and finishes at 10.
- 10 to 11: finishes its CPU burst. Then its I/O runs from 11 to 14.
- 14 to 15: runs its last CPU unit and finishes at 15.
So the finish times of are 10, 15 and 9.
Answer: (B)
Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 10% of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm and schedules a new process either when the running process get blocked on I/O or when the running process finishes its compute burst. Assume that all I/O operations can be overlapped as much as possible. For what percentage of time does the CPU remain idle?
Answer: (B)
Each process spends 20% of its time on I/O, then 70% on the CPU, then 10% on I/O. So the bursts (I/O, CPU, I/O) are P1: 2, 7, 1; P2: 4, 14, 2; P3: 6, 21, 3. All arrive at 0, and I/O can overlap, so all three begin their first I/O together.
- 0-2: all three are in their first I/O, so the CPU is idle for 2 ms.
- 2-9: P1 is ready first and runs its 7 ms. P2 (ready at 4) and P3 (ready at 6) have to wait, because a new process is chosen only when the running one blocks or finishes its compute burst.
- 9-23: P2 (14 ms) is shorter than P3 (21 ms), so P2 runs. P1 does its last 1 ms of I/O at 9-10.
- 23-44: P3 runs its 21 ms. P2 does its last I/O at 23-25.
- 44-47: P3 does its final 3 ms of I/O. No other process is left to use the CPU, so it is idle.
Total time = 47 ms, CPU idle time = 2 + 3 = 5 ms.
Answer: (B)
- 0-2: all three are in their first I/O, so the CPU is idle for 2 ms.
- 2-9: P1 is ready first and runs its 7 ms. P2 (ready at 4) and P3 (ready at 6) have to wait, because a new process is chosen only when the running one blocks or finishes its compute burst.
- 9-23: P2 (14 ms) is shorter than P3 (21 ms), so P2 runs. P1 does its last 1 ms of I/O at 9-10.
- 23-44: P3 runs its 21 ms. P2 does its last I/O at 23-25.
- 44-47: P3 does its final 3 ms of I/O. No other process is left to use the CPU, so it is idle.
Total time = 47 ms, CPU idle time = 2 + 3 = 5 ms.
Answer: (B)
Consider three processes (process id 0,1,2, respectively) with compute time bursts 2,4, and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id . The average turn around time is
Answer: (A)
LRTF always runs the process with the longest remaining time, checked after every time unit. A tie goes to the lowest process id. Remaining times (P0, P1, P2) start at (2, 4, 8).
- 0-4: P2 is longest, so it runs and its remaining time falls from 8 to 4. Now P1 and P2 tie at 4.
- 4-5: the tie goes to P1 (lower id). Remaining (2, 3, 4).
- 5-6: P2 is longest. Remaining (2, 3, 3).
- 6-7: P1 and P2 tie at 3, so P1 runs. Remaining (2, 2, 3).
- 7-8: P2 runs. Remaining (2, 2, 2), a three-way tie.
- 8-9: P0 runs (lowest id). Remaining (1, 2, 2).
- 9-10: P1 runs (tie with P2). Remaining (1, 1, 2).
- 10-11: P2 runs. Remaining (1, 1, 1).
- 11-12: P0 runs and finishes. 12-13: P1 finishes. 13-14: P2 finishes.
A.T. Arrival Time, B.T. Burst Time, C.T. Completion Time, T.A.T. Turn Around Time (C.T. A.T.), W.T. Waiting Time (T.A.T. B.T.)
Average TAT units.
Answer: (A)
- 0-4: P2 is longest, so it runs and its remaining time falls from 8 to 4. Now P1 and P2 tie at 4.
- 4-5: the tie goes to P1 (lower id). Remaining (2, 3, 4).
- 5-6: P2 is longest. Remaining (2, 3, 3).
- 6-7: P1 and P2 tie at 3, so P1 runs. Remaining (2, 2, 3).
- 7-8: P2 runs. Remaining (2, 2, 2), a three-way tie.
- 8-9: P0 runs (lowest id). Remaining (1, 2, 2).
- 9-10: P1 runs (tie with P2). Remaining (1, 1, 2).
- 10-11: P2 runs. Remaining (1, 1, 1).
- 11-12: P0 runs and finishes. 12-13: P1 finishes. 13-14: P2 finishes.
A.T. Arrival Time, B.T. Burst Time, C.T. Completion Time, T.A.T. Turn Around Time (C.T. A.T.), W.T. Waiting Time (T.A.T. B.T.)
Average TAT units.
Answer: (A)
Consider three CPU-intensive processes, which require 10,20 and 30 time units and arrive at times 0,2, and 6, respectively. How many context switches are needed if the operating system implements a shortes remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end
Answer: (B)
Shortest remaining time first (SRTF) always runs the process with the least time left. The Gantt chart:
- : only is present, so it runs.
- : arrives with 20. has 8 left, which is less, so keeps running (no switch).
- : arrives with 30. has 4 left, so it keeps running (no switch).
- : ends. (20) is shorter than (30), so runs. This is switch 1.
- : ends and runs until 60. This is switch 2.
The switch at time 0 and the end at 60 are not counted, so there are 2 context switches.
Answer: (B)
- : only is present, so it runs.
- : arrives with 20. has 8 left, which is less, so keeps running (no switch).
- : arrives with 30. has 4 left, so it keeps running (no switch).
- : ends. (20) is shorter than (30), so runs. This is switch 1.
- : ends and runs until 60. This is switch 2.
The switch at time 0 and the end at 60 are not counted, so there are 2 context switches.
Answer: (B)
For each of the four processes and . The total size in kilobytes (KB) and the number of segments are given below.
The page size is 1 KB. The size of an entry in the page table is 4 bytes. The size of an entry in the segment table is 8 bytes. The maximum size of a segment is 256 KB. The paging method for memory management uses two-level paging, and its storage overhead is P. The storage overhead for the segmentation method is S. The storage overhead for the segmentation and paging method is T. What is the relation among the overheads for the different methods of memory management in the concurrent execution of the above four processes?
The page size is 1 KB. The size of an entry in the page table is 4 bytes. The size of an entry in the segment table is 8 bytes. The maximum size of a segment is 256 KB. The paging method for memory management uses two-level paging, and its storage overhead is P. The storage overhead for the segmentation method is S. The storage overhead for the segmentation and paging method is T. What is the relation among the overheads for the different methods of memory management in the concurrent execution of the above four processes?
Answer: (B)
Paging with 2 levels. The page size is 1 KB and an entry is 4 bytes, so a page holds entries. Assume each page table (outer and inner) is one page in size, since the question does not say. A process of up to 256 pages needs 1 inner table, and a larger one needs 2.
(195 pages), (254) and (45): 1 outer + 1 inner = 2 KB each.
(364 pages, more than 256): 1 outer + 2 inner = 3 KB.
KB bytes.
Segmentation. One segment table entry per segment, 8 bytes each. The total number of segments is .
bytes.
Segmentation with paging. Each process has a segment table, and each segment has its own page table. A segment is at most 256 KB, so its page table has entries of 4 bytes bytes (1 KB). With 20 segments in all, the page tables take KB bytes. Add the segment tables:
bytes.
So bytes.
Answer: (B)
(195 pages), (254) and (45): 1 outer + 1 inner = 2 KB each.
(364 pages, more than 256): 1 outer + 2 inner = 3 KB.
KB bytes.
Segmentation. One segment table entry per segment, 8 bytes each. The total number of segments is .
bytes.
Segmentation with paging. Each process has a segment table, and each segment has its own page table. A segment is at most 256 KB, so its page table has entries of 4 bytes bytes (1 KB). With 20 segments in all, the page tables take KB bytes. Add the segment tables:
bytes.
So bytes.
Answer: (B)