The Processing Cycle

 < Day Day Up > 



Computers are powerful because they can do repetitive things really fast. When the executable code is loaded into main memory the processor can start executing the machine instructions. When a computer executes or runs a program it constantly repeats a series of processing steps commonly referred to as the processing cycle. The processing cycle consists of four primary steps: instruction fetch, instruction decode, instruction execution, and result store. The step names can be shortened to simply fetch, decode, execute, and store. Different processors will implement the processing cycle differently but for the most part these four processing steps are being carried out in some form or another.

click to expand
Figure 4-7: Processing Cycle

Fetch

In the fetch step, an instruction is read from main memory and presented to the decode section of the processor. If the requested memory address contents resides in cache memory the read operation will happen quickly. Otherwise, the processor will have to wait for the data to be accessed from main memory, which has a slower access time than does cache memory.

Decode

In the decode step, the instruction fetched from main memory is decoded. If the computer thinks it is getting an instruction but instead it gets garbage there will be problems. A computer system’s ability to recover from such situations is generally a function of a robust operating system.

Execute

If the fetched instruction is successfully decoded, meaning it is a valid instruction in the processor’s instruction set, it is executed. A computer is a bunch of switches. Executing an instruction means the computer’s electronic switches are switched either on or off, and clocked in a particular fashion to carry out the particular instruction.

Store

After an instruction is executed the results of the execution, if any, must be stored somewhere. Most arithmetic instructions leave the result in one of the processor’s onboard registers. Memory write instructions would then be used to transfer the results to main memory. Keep in mind that there is only so much storage space inside of a processor. At any given time, almost all data and instructions reside in main memory, and are only loaded into the processor when needed.

Why A Program Crashes

Notwithstanding catastrophic hardware failure, a computer crashes or locks up because what it was told was an instruction was not! The faulty instruction loaded from memory turns out to be an unrecognizable string of 1’s and 0’s and when it fails to decode into a proper instruction the computer halts.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net