The purpose of the CPU

Purpose of the Central Processing Unit ( CPU)

The purpose of the CPU is to carry out the set of instructions given to the processor from  a program.

This is done through a combination of:

  • Arithmetic
  • logic
  • input / output operations
  • control operations.

Instructions are usually written by programmers in high level languages because they are easier for humans and write, understand and maintain, but these need to translated in to the binary instructions that a computer can process.

Compiling vs Interpreting

With some programming languages (such as C) this translation needs to be done before you can run the script, using a process known as compiling. These programming languages tend to be highly efficient and therefore good for processor intensive tasks, e.g. 3D Gaming, Video Editing.

With other languages (such as Python) this translation is done as the script is being executed; this is a process known as interpreting. Interpreted languages tend to be much quicker to develop (because your script does not need to be compiled every time you make a change to the file) but are less efficient than the compile languages.

Programmer code in high level code.

This needs to be translated into machine code.

The CPU processes the machine code by turning on/off the correct transistors. Modern CPUs contain billions of tiny transistors.

 

 

 

 

 

 

Purpose of the CPU

AMD CPU

 

Location of the CPU

The CPU is located on the motherboard, in the CPU socket.

The CPU produces a great deal of heat, which needs to be drawn away quickly, otherwise the CPU would overheat. You usually cannot see the CPU because it is normally hidden by the heat-sink and the CPU fan. The heat-sink is usually a large cube shaped piece of metal with lots of fins. On top of the heat-sink sits a fan, which blows the heat away from the heat-sink and into the PC case.

The heat-sink is normally bonded to the CPU with a special thermal paste, this is because otherwise there would be a tiny layer of air between the CPU and the heat-sink and this would interfere with the conduction of heat from the CPU to the heatsink.

Micro-controllers like the Raspberry Pi usually don’t need a heat-sink and fan fitted, because they are highly efficient low-power processors(the same as the ones used in a mid-range smartphone) but sometimes if they are used as media centres or over-clocked for gaming, then a heat-sink might be used.

Click to enlarge any of the images below

The CPU socket, with CPU removed.

CPU Heat-sink with fan connected

Thermal Paste, ready to by applied to the top of the CPU

 

 

 

 

 

 

 

Example 1 – Displaying a cat image on screen

To display an image of a cat the computer needs to:

  • INPUTWait for the user to click their mouse on a cat link.
  • CONTROL – Tell the hard drive to look for that image on the disk
  • LOGIC – If the hard drive can find the image, send the image to the main memory
  • ARITHMETIC  – Calculate where on the screen each pixel is to be displayed
  • OUTPUT – For each pixel tell the LCD monitor it’s RGB value (the screen calculated how bright to turn on each RGB LED

LCD Screens are made up of millions of red,green,blue (RGB) LEDs which can all be independently controlled.

CPU Performance

CPU performance is affected by a number of key characteristics:

Clock Speed

The clock speed is the number of instructions per second that the a CPU can process, and is currently usually measured in GigaHertz GHz

a 3.2 Ghz processor can process 3,200,000,000 processes per second, in theory. This is dependent of course on the processor receiving all the instructions it needs from the main memory.

Cache Size

In order to ensure that the next instruction is loaded and ready to be processed by the CPU, commonly executed instructions are stored in the Cache memory area of the CPU. The larger the cache memory, the more commonly used instructions can stored and therefore it is less likely that the CPU will have to stop and wait for instructions to be loaded. Modern CPUs have a cache size up to 1 or 2 Megabytes.

Number of cores

Many modern computers contain dual, quad or even 8 core processors (effectively 8 separate CPUs on one chip). Most computers are used used for multitasking applications, for example you might be listening to music playing on YouTube at the same time as playing a computer game. The most efficient way to handle multitasking is to assign one core of the processor to one particular application. This means that if one core has to wait from data to load from the hard disk, the other cores are not affected.

The overall theoretical speed of a processor can be calculated by multiplying the number of cores by the processor speed.

e.g.

  • 4.2 Ghz Dual Core processor = 4.2 x 2 = 8.4Ghz
  • 2.2 Ghz Quad Core processor =  2.2 x 4  = 8.8Ghz

Although the 4.2 Ghz processor has a higher base speed, the quad core processor has a higher effective speed.

Quad core processors only run faster than single core processors if the operating system and software being used is able to take advantage of multi-threading, otherwise the extra cores will merely sit idle.

Clicking on the performance tab in task manager (on windows 7+) will show you how many processors your computer has and how well they are being used) Here a quad core processor is installed.

Activity

Describe the processing for 2 of the options below:

  • Printing out a word processing document
  • Playing a music file
  • Resizing an image
  • Recording sound using the computer’s microphone

Test your knowledge of the CPU in this quiz