- Practice
- About 13 min
- 5 practice questions
Numerical OS questions: time slices, pages, frames and waiting time
Solve the four numerical question types that appear in operating system papers using a short fixed method for each.
If something looks wrong, please tell us.
Most operating system questions are definitions, but a few are small calculations. They look unfamiliar, yet each one follows a fixed method that takes under a minute. All the numbers here are illustrative practice values.
Type 1: the length of a round (time slices)
Method: round length = number of users or processes x time slice. The wait between two turns of one process = (number of processes - 1) x time slice.
Type 2: pages needed
Method: pages = program size / page size, rounded up. Unused space in the last page = pages x page size - program size. That wasted space is internal fragmentation.
Type 3: frames in RAM
Method: frames = RAM size / frame size. A frame holds one page, so a program of n pages needs n free frames if it is to be fully loaded.
Type 4: waiting and turnaround time (FCFS)
Method: list the processes in arrival order. A process's waiting time = the total burst time of those before it (when all arrive at time 0). Turnaround time = waiting time + its own burst time. Average = total / number of processes.
| Type | Formula | Watch out for |
|---|---|---|
| Round length | users x slice | Units (ms or seconds) |
| Pages | size / page size, round up | Rounding down loses the last part |
| Frames | RAM / frame size | Same units for both numbers |
| Waiting time | sum of earlier bursts | Order of arrival decides it |
Worked example 1: round length
Twelve users share a time-sharing system with a time slice of 40 ms. One full round = 12 x 40 = 480 ms. A user waits between turns = (12 - 1) x 40 = 11 x 40 = 440 ms.
Worked example 2: pages and waste
A program of 50 KB is loaded with 8 KB pages. 50 / 8 = 6.25, so 7 pages are needed. Space allocated = 7 x 8 = 56 KB. Wasted in the last page = 56 - 50 = 6 KB. A common mistake is to answer 6 pages.
Worked example 3: frames
RAM is 256 KB and each frame is 16 KB. Frames = 256 / 16 = 16. If the program above needs 7 pages, there are 16 - 7 = 9 frames left for other programs.
Worked example 4: FCFS
Three processes P1, P2 and P3 arrive together with bursts 5, 4 and 2 ms in that order. Waiting times: P1 = 0, P2 = 5, P3 = 5 + 4 = 9. Average waiting = (0 + 5 + 9) / 3 = 14 / 3 = 4.67 ms. Turnaround times: P1 = 5, P2 = 5 + 4 = 9, P3 = 9 + 2 = 11. Average turnaround = (5 + 9 + 11) / 3 = 25 / 3 = 8.33 ms.
Round = users x slice. Pages = size / page, rounded up. Frames = RAM / frame. Waiting = bursts before it.
Common traps
- Rounding a page count down instead of up.
- Mixing KB and MB in one division.
- Using (users x slice) for the wait between turns instead of (users - 1) x slice.
- Counting the process's own burst in its waiting time.
Check your understanding
-
1. Ten processes share the CPU with a time slice of 30 ms each. How long is one full round?
- 300 ms
- 270 ms
- 30 ms
- 330 ms
Show answer
Answer: A. 10 x 30 = 300 ms.
-
2. A 30 KB program uses 4 KB pages. How many pages does it need?
- 7
- 6
- 9
- 8
Show answer
Answer: D. 30 / 4 = 7.5, rounded up to 8 pages.
-
3. RAM of 128 KB is divided into frames of 8 KB. How many frames are there?
- 8
- 16
- 32
- 12
Show answer
Answer: B. 128 / 8 = 16 frames.
-
4. Under FCFS, bursts 3, 6 and 1 arrive together in that order. What is the waiting time of the third process?
- 3 ms
- 6 ms
- 9 ms
- 10 ms
Show answer
Answer: C. It waits for 3 + 6 = 9 ms before it starts.
-
5. A program of 18 KB is loaded into 4 KB pages. How much space is wasted in its last page?
- 2 KB
- 3 KB
- 1 KB
- 4 KB
Show answer
Answer: A. 18 / 4 = 4.5, so 5 pages = 20 KB are allocated. Waste = 20 - 18 = 2 KB.
Sign in to keep track of the lessons you finish.