Skip to content

9618 · 5.1

Operating Systems — practice questions

Practice and worked examples for 9618 Operating Systems. Short previews only — attempt the full question in MarkScheme against the official scheme.

Worked example 1

A computer system uses paging for memory management. The page size is 4 KB (4096 bytes). A program requires a logical address of 18000. Calculate: (i) The page number. (ii) The offset within the page. (iii) If this page is mapped to physical frame 7, what is the physical address?

Show solution outline

(i) Page Number: To find the page number, we perform integer division of the logical address by the page size. Page Number = FLOOR(Logical Address / Page Size) Page Number = FLOOR(18000 / 4096) = FLOOR(4.3945...) = 4. So, the logical address is in page 4. [1 mark]

(ii) Offset: The offset is the remainder of the division, or can be calculated using the modulo operator. Offset = Logical Address MOD Page Size Offset = 18000 MOD 4096 = 1616. Alternatively: 18000(44096)=1800016384=161618000 - (4 * 4096) = 18000 - 16384 = 1616. The offset is 1616. [1 mark]

(iii) Physical Address: The physical address is calculated by multiplying the frame number by the page size and adding the offset. Physical Address = (Frame Number * Page Size) + Offset Physical Address = (7 * 4096) + 1616 Physical Address = 28672 + 1616 = 30288. [1 mark]

Worked example 2

Four processes arrive in the ready queue in the order P1, P2, P3, P4. Their CPU burst times are 6ms, 4ms, 8ms, and 2ms respectively. The system uses the Round Robin scheduling algorithm with a time quantum of 3ms. Draw a Gantt chart to show the execution of these processes and state the order in which they complete.

Show solution outline

The time quantum is 3ms. Processes are executed in a circular queue (P1, P2, P3, P4).

Gantt Chart: The chart shows which process is running at each time interval.

P1P2P3P4P1P2P3P3
0 3 6 9 11 14 15 18 20 (ms)

Execution Trace:

  • 0-3ms: P1 runs for 3ms. Remaining time for P1 = 6 - 3 = 3ms. Queue: P2, P3, P4, P1.
  • 3-6ms: P2 runs for 3ms. Remaining time for P2 = 4 - 3 = 1ms. Queue: P3, P4, P1, P2.
  • 6-9ms: P3 runs for 3ms. Remaining time for P3 = 8 - 3 = 5ms. Queue: P4, P1, P2, P3.
  • 9-11ms: P4 runs for 2ms. It completes. Remaining time = 0. Queue: P1, P2, P3. P4 completes. [1 mark]
  • 11-14ms: P1 runs for its remaining 3ms. It completes. Remaining time = 0. Queue: P2, P3. P1 completes. [1 mark]
  • 14-15ms: P2 runs for its remaining 1ms. It completes. Remaining time = 0. Queue: P3. P2 completes. [1 mark]
  • 15-18ms: P3 runs for 3ms. Remaining time = 5 - 3 = 2ms. Queue: P3.
  • 18-20ms: P3 runs for its remaining 2ms. It completes. P3 completes. [1 mark]

Order of completion: P4, P1, P2, P3. [1 mark]