Member-only story

Operating System — The Basic Process of Program Execution

Tony
6 min readDec 15, 2023

A program is actually a series of instructions, so the process of running a program is to execute each instruction step by step, and the CPU is responsible for executing these instructions.

Program Execution Steps

The process of the CPU executing a program is outlined in the follows:

  • Step one: The CPU looks at the “program counter” to fetch the memory address where the current instruction is stored. The CPU’s “control unit” then uses the “address bus” to pinpoint the required memory location. It signals the memory to get ready to send data, and once the data is prepped, it’s shuttled over to the CPU through the “data bus.” The CPU, upon receiving this data, stores the incoming instruction into the “instruction register.”
  • Step two: The “program counter” increases its value to point to the next instruction. How much it increases by is determined by the CPU’s architecture — for instance, with a 32-bit CPU, instructions are 4 bytes, therefore the program counter jumps ahead by 4 to align with the next instruction’s memory location.
  • Step three: The CPU deciphers the instruction that’s currently in the “instruction register,” figuring out what operation is to be performed and what the operands are. If it’s an operation that requires…

--

--

Tony
Tony

No responses yet