අන්තර්ගතයට යන්න
mcqdinethlive

Fetch-execute cycle and operating system lessons in the right learning order

The fetch-execute cycle and the OS lesson as one story. The order to learn the pieces and why, one program from double-click to exit, how the exam tests it, what is current today and where it comes back in Grade 13.

සිංහලෙන් කියවන්න

This post shows that the fetch-execute cycle of Unit 2 and the operating system lesson of Unit 5 are one story about one program. Process states, the PCB, paging and FAT can look like four new subjects. They are not. The books tell the story in pieces, and many students meet the OS words before the earlier words are firm.

The post has four parts:

  • The order: why these lessons feel tangled, and the order to learn the pieces with the reason for each step (sections 1 and 2).
  • The story: one program from a double-click to its exit (section 3).
  • The exam: how the papers test this story, the question types and two worked examples (sections 4 and 5).
  • Beyond the books: what is current in real computers today, where the ideas come back in Grade 13, and past paper questions to try (sections 6 to 8).

1. Why these lessons feel tangled

The syllabus splits the story across five units of Grade 12. Students meet the computer parts in Unit 1, the CPU in Unit 2, binary in Unit 3, flip-flops in Unit 4 and the OS in Unit 5. The syllabus gives these units 28, 22, 18, 26 and 22 periods (Syllabus, page ix) (විෂය නිර්දේශය, පිටුව viii).

Each unit uses words from the units before it:

  • Unit 5 uses Unit 2 words. The Process Control Block keeps the program counter, "a pointer to the address of the next instruction to be executed for this process" (Teachers' Guide 5.3, page 136) (ගුරු අත්පොත 5.3, පිටුව 147). That is the same program counter as in the fetch-execute cycle (2.3). The Sinhala Teachers' Guide calls the PCB "ක්‍රියායන පාලන ඛණ්ඩය" and the program counter "වැඩසටහන් ගණකය".
  • Unit 5 uses Unit 3 numbers. Frames have a size that "is power of 2" (Teachers' Guide 5.4, page 141) (ගුරු අත්පොත 5.4, පිටුව 153). Every paging sum is a powers-of-two sum (3.1).
  • Unit 5 uses Unit 4 circuits. A register is a row of flip-flops (4.4). The OS saves registers at every context switch.

So the problem is not that the OS lesson is hard. The problem is that a student meets the OS words before the earlier words are firm.

2. The learning order step by step

Here is the order we suggest. It is not a rule in the books. It follows one test: learn an idea only after every word it uses is known.

  1. Hardware, software and the OS layer (1.4, 5.1). Know what sits where. The OS is system software. It hides hardware details, manages resources and runs application software (Teachers' Guide 5.1, page 123) (ගුරු අත්පොත 5.1, පිටුව 133).
  2. The stored program and the fetch-execute cycle (2.3). The program sits in memory. The CPU takes one instruction at a time from memory and executes it (Teachers' Guide 2.3, page 67) (ගුරු අත්පොත 2.3, පිටුව 72). The cycle is fetch, decode, execute (Teachers' Guide 2.3, page 68) (ගුරු අත්පොත 2.3, පිටුව 73). The Sinhala Teachers' Guide calls it "සෙවුම්-ඉෂ්ට චක්‍රය". Learn the program counter here.
  3. Memory types and storage (2.4). Registers, cache and RAM are volatile. Disks keep data without power (Teachers' Guide 2.4, pages 70 and 71) (ගුරු අත්පොත 2.4, පිටු 77 සහ 78). The Sinhala Teachers' Guide calls them "නශ්‍ය මතකය" and "නශ්‍ය නොවන මතකය". This step shows why a program must move from disk to RAM before it runs.
  4. Binary sizes and registers (3.1, 4.4). Practise 2 to the power n, and bits to bytes. Know that a register is built from flip-flops. Every paging question needs this.
  5. Processes, interrupts and context switch (5.3). "A process is basically a program in execution" (Teachers' Guide 5.3, page 134) (ගුරු අත්පොත 5.3, පිටුව 145). The Sinhala Teachers' Guide calls a process "ක්‍රියායනය". Now steps 2 and 4 pay back. A context switch saves the registers, including the program counter, into the PCB (Teachers' Guide 5.3, page 137) (ගුරු අත්පොත 5.3, පිටුව 148).
  6. Memory management and paging (5.4). Steps 3 and 4 pay back. The MMU is the "hardware device that maps virtual to physical address" (Teachers' Guide 5.4, page 141) (ගුරු අත්පොත 5.4, පිටුව 152).
  7. Files and disk blocks (5.2). Step 3 pays back. A file system controls "how data is stored and retrieved" on secondary storage (Teachers' Guide 5.2, page 128) (ගුරු අත්පොත 5.2, පිටුව 139).

The syllabus puts files (5.2) before processes (5.3). That order is fine in class. For revision, take 5.3 and 5.4 right after the fetch-execute cycle, because they use it directly. Files use the disk, not the CPU cycle, so they can come last.

3. One program from double-click to exit

The seven steps join into one story when one program is followed from start to end. The program here is a spreadsheet, from the moment a user double-clicks it. Each stage names its level.

  1. Find the file (5.2). The program is a file on disk. In a FAT file system, the File Allocation Table keeps track of the file's blocks, and each block links to the next one (Teachers' Guide 5.2, pages 128 and 130) (ගුරු අත්පොත 5.2, පිටු 139 සහ 141). The exam adds that the directory entry holds the first block number, as in 2023 (held 2024) Paper II, B, Q10(f).
  2. Load it into memory (5.4). The OS splits the program into pages and puts them in free frames. It sets up a page table to translate logical to physical addresses (Teachers' Guide 5.4, page 141) (ගුරු අත්පොත 5.4, පිටු 152 සහ 153).
  3. Make a process (5.3). The OS makes a PCB with the process ID, state, program counter, registers and memory information (Teachers' Guide 5.3, page 136) (ගුරු අත්පොත 5.3, පිටුව 147). The new process is marked Ready (Teachers' Guide 5.3, page 136) (ගුරු අත්පොත 5.3, පිටුව 147).
  4. Run it (2.3, 5.3). The short-term scheduler, the dispatcher, gives the CPU to the process (Teachers' Guide 5.3, page 138) (ගුරු අත්පොත 5.3, පිටුව 149). Now the fetch-execute cycle runs its instructions. The program counter says which instruction comes next.
  5. Wait for the disk (5.3). The program asks to read a file. The disk is slow, so the process becomes Blocked. The CPU runs another process meanwhile. This is multiprogramming. When a program waits for I/O, the "OS switches processor to execute another program in memory" (Teachers' Guide 5.1, page 124) (ගුරු අත්පොත 5.1, පිටුව 135).
  6. Interrupt and context switch (5.3). An interrupt "is an event that alters the sequence of execution of process". It can come from a time expiry, a service request or I/O completion (Teachers' Guide 5.3, page 135) (ගුරු අත්පොත 5.3, පිටුව 145). The Sinhala Teachers' Guide calls an interrupt "අතුරුබිඳුම" and a context switch "සන්දර්භ ස්විචය". At a switch, the OS saves "the content of all processor registers" of the old process in its PCB (Teachers' Guide 5.3, page 137) (ගුරු අත්පොත 5.3, පිටුව 148).
  7. Run again from the same place (2.3, 5.3). The OS loads the saved program counter back. The fetch-execute cycle goes on from the next instruction, as if nothing happened.
  8. Print and exit (5.4, 5.3). The printout goes through a device driver and a spool, a buffer that holds the data "while the slower device catches up" (Teachers' Guide 5.4, page 143) (ගුරු අත්පොත 5.4, පිටුව 154). On exit, the "OS reclaims all resources assigned to the process" (Teachers' Guide 5.3, page 134) (ගුරු අත්පොත 5.3, පිටුව 145).

The levels in this list jump between 2.3, 5.2, 5.3 and 5.4 all the time. That is why the exam can join them in one question.

4. How the exam tests it

The papers test this story every year: an OS question in every Paper II, and the fetch-execute parts in Paper I. The counts here cover the eight new-syllabus papers from 2019 to 2026. The keys for 2022 (held 2023) and 2024 come from third-party schemes. The 2023 (held 2024) Paper II marks are estimates, because that year has no scheme.

Paper II always has an OS question

Every new-syllabus Paper II has a structured question on the OS. Its Unit 5 parts carry 9 to 15 marks, 87 marks over the eight papers.

  • In 2019, 2020, 2025 and 2026, it is Part A, Q4, a whole question on the OS.
  • From 2021 (held 2022) to 2024, it is Part B, Q10. Some years, that question also asks about earlier units.

That last point matters most. 2024 Paper II, B, Q10 starts with the CPU instructions for one Python statement (2.3), then asks a two's complement sum (3.3), then process states and the program counter at a context switch (5.3), then paging (5.4), then file allocation (5.2). 2023 (held 2024) Paper II, B, Q10 starts with "the repeating cycle" a processor runs while the computer is on (2.3), asks how many flip-flops an n-bit register needs (4.4), then goes on to the PCB, paging and FAT. These questions follow the same story as section 3.

Paper I follows the syllabus order

Paper I asks its MCQs roughly in syllabus order. In 2026 Paper I, Q1 and Q2 are on data processing (1.5), Q3 is on storage (2.4), and Q4 and Q5 are on buses and the program counter (2.3). Number systems start at Q6.

The Unit 5 MCQs have moved. There were 3 to 5 in each paper from 2019 to 2024. There were none in 2025 and 2026. In the same two years, Unit 2 had 6 MCQs (2025, its highest count) and 3 MCQs (2026). So recent papers test the fetch-execute parts in Paper I and the OS parts in Paper II. Two years is a short trend, so keep OS MCQs in practice.

5. Question types to expect

The past questions fall into a small set of types. Learn the types, and a new question will look familiar.

  1. Name the part (2.3). Which bus carries the read signal? Which register holds the address of the next instruction? See 2025 Paper I, Q6 and Q7, and 2026 Paper I, Q4 and Q5.
  2. Steps of the cycle (2.3). List the steps, or write the instructions a CPU needs for one statement. See 2020 Paper II, A, Q3(a)(ii) and 2024 Paper II, B, Q10(a).
  3. State change and its cause (5.3). A process waits for a web server, or for the disk. Which transition happens? See 2024 Paper II, B, Q10(c)(i) and (ii), and 2025 Paper II, A, Q4(a).
  4. Context switch (5.3). What is saved, where, and why the time is overhead. The Guide says "Context switch time is pure overhead" (Teachers' Guide 5.3, page 137) (ගුරු අත්පොත 5.3, පිටුව 148). The Sinhala Guide says the time is "අමතර වැය කිරීමකි". See 2026 Paper II, A, Q4(b).
  5. Paging numbers (5.4). Count frames, find the bits for a frame number, or translate a virtual address. See 2026 Paper II, A, Q4(c), 2024 Paper II, B, Q10(d)(i) and (ii), and 2023 (held 2024) Paper II, B, Q10(e).
  6. Page table bits (5.4). What a valid bit of 0 means, and why a modified bit helps. See 2024 Paper II, B, Q10(d)(iii) and (iv).
  7. File allocation (5.2). Follow a FAT chain, count blocks, find internal fragmentation, or pick linked or indexed allocation. See 2026 Paper II, A, Q4(a), 2025 Paper II, A, Q4(c) and 2023 (held 2024) Paper II, B, Q10(f).
  8. Explain why (5.1, 5.4). Why does a printer need a driver? How can a program bigger than RAM run? How do many programs run on one processor? See 2026 Paper II, A, Q4(d) and 2021 (held 2022) Paper II, B, Q10(c).
  9. Cross-unit links (2.3, 4.4, 5.3). Flip-flops in a register, whose instructions run during a context switch, or where the PCB sits in memory. See 2023 (held 2024) Paper II, B, Q10(a) and (b).

A worked paging example

Type 5 scares many students, but it is only Unit 3 arithmetic. Here is our own example, not a past question.

A computer uses 16-bit virtual addresses and a page size of 4 KB. The page table says page 1 is in frame 6. Find the physical address for virtual address 5000.

Page size     = 4 KB = 4096 = 2^12 bytes, so the offset uses 12 bits
Page number   = 5000 div 4096 = 1
Offset        = 5000 - 4096   = 904
Frame         = 6, read from the page table
Physical      = 6 x 4096 + 904 = 24576 + 904 = 25480

The offset never changes. Only the page number becomes a frame number. With 16-bit addresses and a 12-bit offset, 4 bits are left for the page number, so a process can have 2^4 = 16 pages.

A worked FAT example

This one is also our own. A file starts at block 3. The FAT has 7 in entry 3, 4 in entry 7 and -1 in entry 4. So the file uses blocks 3, 7 and 4, in that order, and -1 marks the end. With 4 KB blocks, the file takes 12 KB of disk. If the file holds only 9 KB of data, the last block wastes 3 KB. That waste inside a block is internal fragmentation.

6. What is current in the real world

Real computers in 2026 still use the ideas in the books, with some changes. The exam sometimes sets a question with modern numbers, so students need both.

  • Many cores, one idea. A multi-core processor has "two or more independent actual processing units" (Teachers' Guide 2.3, page 68) (ගුරු අත්පොත 2.3, පිටුව 74). Each core runs its own fetch-execute cycle. The OS scheduler now picks a process or thread for each core, not only for one CPU. The process states stay the same.
  • Bigger addresses, same paging. 2026 Paper II, A, Q4(c) uses 48-bit virtual addresses and 4 KB pages. Those numbers come from real machines. Current x86-64 processors use 48-bit virtual addresses, and newer ones can use 57 bits (x86-64). A 4 KB page is still the common size (Page). The Guide gives frame sizes "between 512 bytes and 8192 bytes" (Teachers' Guide 5.4, page 141) (ගුරු අත්පොත 5.4, පිටුව 153), and 4 KB sits inside that range.
  • Defragmentation is for spinning disks. Defragmentation rearranges file pieces on a disk (Teachers' Guide 5.2, page 129) (ගුරු අත්පොත 5.2, පිටුව 140). A hard disk gets faster from it, because its head moves less. A solid-state drive has no head. On an SSD, the OS sends TRIM commands to tell the drive which blocks are free (Trim).
  • FAT is still alive. The Guide calls FAT the file system of MS-DOS (Teachers' Guide 5.2, page 128) (ගුරු අත්පොත 5.2, පිටුව 139). Its later forms, FAT32 and exFAT, are still common on memory cards and USB drives (exFAT). So the FAT chain in Paper II is not only history.
  • Real-time systems are everywhere. A real-time OS gives "quick and predictable response to events", for cases where a delay "could cause a safety hazard" (Teachers' Guide 5.1, page 125) (ගුරු අත්පොත 5.1, පිටුව 136). This links to the embedded systems of Unit 11.

7. Where these ideas come back later

The fetch-execute cycle and the OS do not end in Grade 12. They come back in Grade 13 units, often without their names.

  • Program translators (9.5). The syllabus lists source program, object program, interpreters and compilers (Syllabus 9.5, pages 37 and 38) (විෂය නිර්දේශය 9.5, පිටුව 35). The object program is the machine instructions that the fetch-execute cycle runs.
  • File handling in programs (9.11). When a Python program opens a file, it asks the OS for it (Syllabus 9.11, page 40) (විෂය නිර්දේශය 9.11, පිටුව 37). The OS then uses the file system from 5.2.
  • Parallel and grid computing (2.2). The syllabus asks for "the need for parallel and grid computing" (Syllabus 2.2, pages 7 and 8) (විෂය නිර්දේශය 2.2, පිටුව 8). It is the multi-core idea, spread over many machines.
  • Embedded systems (11.1). The syllabus compares boards such as Arduino with traditional computer systems (Syllabus 11.1, pages 45 and 46) (විෂය නිර්දේශය 11.1, පිටු 42 සහ 43). A simple board runs one program in a loop, close to the hardware. It is the fetch-execute cycle with little or no OS.
  • Beyond von Neumann (13.3). The syllabus asks about computing "beyond von-Neumann" (Syllabus 13.3, page 49) (විෂය නිර්දේශය 13.3, පිටුව 47). Students need the stored program and the fetch-execute cycle to see what is beyond them.

The full von Neumann story, with the bottleneck and the new models, is in Von Neumann architecture from stored program to bottleneck. The circuit side, from adders to flip-flops to memory, is in Binary to memory through adders and flip-flops.

8. Past paper questions to try

Try each question before reading any answer. The section in brackets is the part of this post that helps with it. The answers are not in this post.

Whole-story questions, try these last:

  • 2024 Paper II, B, Q10: one program from CPU instructions to file allocation (sections 3 and 5).
  • 2023 (held 2024) Paper II, B, Q10: the cycle, flip-flops, the PCB, paging and FAT (sections 3 and 5).
  • 2021 (held 2022) Paper II, B, Q10: multi-core, volatile memory, time sharing, virtual memory and linked allocation (sections 2 and 6).

Questions on one stage:

  • 2025 Paper I, Q6 and Q7, 2026 Paper I, Q4 and Q5: buses, registers and the program counter (section 2).
  • 2021 (held 2022) Paper I, Q4: loading a program and the fetch-decode-execute cycle (section 3).
  • 2025 Paper II, A, Q4(a) and 2026 Paper II, A, Q4(b): process states, the PCB and context switch (sections 3 and 5).
  • 2022 (held 2023) Paper II, B, Q10(a) to (d): context switch, a shorter time slice and paging (sections 3 and 5).
  • 2026 Paper II, A, Q4(c) and 2025 Paper II, A, Q4(b): paging and page faults (section 5).
  • 2026 Paper II, A, Q4(a) and 2025 Paper II, A, Q4(c): FAT chains and block size (section 5).
  • 2026 Paper II, A, Q4(d) and 2024 Paper I, Q6: device drivers and booting (sections 3 and 5).

Old syllabus, for extra practice only:

  • 2013 Paper II, A, Q2(c) and 2015 Paper II, A, Q4(b): the seven-state diagram (section 3).
  • 2018 Paper II, A, Q4(d): frames and the page table (section 5).

Sources outside the syllabus

The syllabus and Teachers' Guide pages of both media are cited in the text. The past papers are the G.C.E. (A/L) ICT question papers of the Department of Examinations, Sri Lanka. These are the other sources:

  • x86-64, virtual address size. Wikipedia.
  • Page (computer memory), common page sizes. Wikipedia.
  • Trim (computing), SSD free-block commands. Wikipedia.
  • exFAT, the FAT family on flash media. Wikipedia.

මේ Explained එක බෙදාගන්න

A/L ICT කරන යාළුවෙකුට යවන්න.

මේ ලිපියට link කරන ලිපි

  1. English

    OS calculations in Paper II with FAT chains and page tables

    The operating system calculations in every A/L ICT Paper II. FAT chains, blocks and wasted space, choosing an allocation method, page and frame bits, and address translation, each worked on real past paper questions.

  2. English

    Learn the fetch-execute cycle before the OS lesson

    The OS lesson feels like a pile of words when the fetch-execute cycle is not clear yet. One learning order makes Unit 5 click, and it matters in Paper II.

තවත් Explained

  1. Layer 2 vs Layer 3 switch differences and real uses

    How a Layer 2 switch and a Layer 3 switch differ, why each exists, where networks use them now and next, and the A/L ICT past paper questions that test them, with answers.

    Englishපියවර 7ක්
  2. A/L ICT second attempt study plan for 2027 by unit weight and past papers

    A study plan for students who sit A/L ICT again in 2027. It covers the 2026 results, the units that carry most marks, a lesson method with past papers, a month by month timeline and the free papers on this site.

    Englishපියවර 7ක්
  3. Python functions with lists of tuples and sequential search in 2026 Paper II Q9

    2026 Paper II Q9 worked part by part. The fine rule and its two readings, a function with if and elif, a list of tuples built with a loop, a sequential search that returns -1, and the same skills in Paper I.

    Englishපියවර 7ක්
All Explained