Processor Model

Understanding how an operating system works is a lot easier when one has a clear grasp of how a computer (processor) works.  In this section we present a model of a processor.  In particular we focus on how the computer executes instructions one at a time and the implications of this process on operating system design.

Remember, we cannot describe how every real processor works (e.g. the Intel processor family), so we must instead provide a functional mental model that describes in principle how every processor works.  Thus, our model will not be precisely accurate for any particular real processor, but it will be functional in terms of what is expected of real processors.

Instruction Execution

All processors of the type we discuss here (so called von Neumann processors) are quite simple in principle.  Their sole function is to execute individual instructions one at a time as they appear in sequence in a program.  Remember the following things.

bulletThe processor of a computer executes instructions one a time in sequence.
bulletThe processor has absolutely no knowledge of user programs or operating systems, or which program the instructions it is currently executing belongs to
bulletThe instructions being executed by the processor are machine language instructions (think assembly language).
bulletThe high level language (e.g., C, Java, etc.) programs written by programmers must first be compiled, or translated, into the machine language of the processor in question.
bulletEach high level language instruction, say

      x = a + b*c

is typically translated into many individual machine language instructions, for instance

      push 0(D0)   -- push a's value onto the stack
      push 4(D0)   -- push b's value onto the stack
      push 12(D0) -- push c's value onto the stack
      muls            -- pop the top two stack values, multiply them, push the result onto the stack
      adds            -- pop the top two stack values, add them, push the result onto the stack
      pop 8(D0)    -- pop the top stack value and store its result into x's address
 
bulletIt is easy for a person to envision the processor executing the individual statements of some high level language program one at a time.  As a mental model of program execution, that view is fine for students who are new to programming.  In order to understand advanced concepts in computer science (e.g., operating systems), however, that view will lead to misunderstandings.  So, if your mental model of program execution is based on high level language statements, it's time to tune your model a bit. 

So, let's assume that we have this all straight from now on.  The processor simply performs the task for which it was designed--executing machine language instructions one at a time in sequence--without any awareness of the programs being executed.

The Instruction Fetch and Execute Cycle

We refer to the hardware circuitry that performs this repetitive process of executing individual instructions sequentially as the instruction fetch and execute cycle.  We illustrate this process in the following diagram.

Instruction Fetch and Execute Cycle
Version 1

Once again, it is important to note that in this view of instruction execution, the processor has no awareness of which program an instruction belongs to.  It could be executing instructions in the operating system or in a user program (e.g. a word processing program).  It doesn't know and doesn't care.