CPU

Share

What is a CPU?

The term CPU has multiple meanings:

  1. Central Processing Unit, an internal physical component (hardware) in your computer that does most of the data processing. Every computer (desktop PC, laptop, smartphone, etc.) has a CPU. This CPU is a chip that you place into the computer's motherboard.
  2. Colloquially, the "CPU" of the computer refers to the black box that has the button to turn on the computer (the power button). This black box also has various ports where you plug your keyboard, mouse, monitor, modem/router, and other peripherals. The actual CPU chip is inside this box. This black box with its components inside is also called the computer tower. The box itself is called the case.
  3. A processor that does the job of a CPU. Modern CPUs have multiple "cores" and each core is essentially a CPU itself. If you ever see "CPU 1," "CPU 2," "CPU 3," etc. in you computer, it's referring to cores of your CPU.
  4. In video-games, specially of fighting and racing genres, a CPU, as in "player vs. CPU," as opposed to "player vs. player," is a player-like character that is controlled by the CPU (i.e. by the computer, by the software, by the console, etc.).

What is a CPU in the Computer?

Colloquially, the CPU is the black box where all the internal computer components are. This "CPU" is plugged into the power outlet, has a power button, you plug input devices such as keyboard and mouse into it, and output devices such as the monitor and speakers.

Inside this "CPU" you'll find the motherboard and other internal computer components.

Warning: while it's very easy to open the PC case and inspect internal computer components, it's also very easy to damage your computer. It's even possible to damage electronic components just by touching them (because of static electricity). On top of that, if you bought a computer that a company built for you, and they gave you a warranty, that could mean the warranty will be voided if you open the case (some companies even place locks or stickers in the case because of this).

Most of the things you plug into the "CPU" are actually plugged into the motherboard. The CPU chip is just one chip installed on the motherboard, and all data that comes and goes to other computer parts must go through the motherboard in order to reach the CPU chip.

There are a few exceptions.

If you have an integrated graphics card, that means your CPU chip does the graphics processing, and you plug your monitor into your motherboard. If you have a dedicated graphics card (e.g. Nvidia's), that means you plug your monitor into a GPU that's inside the "CPU" but that has a port which is exposed outside, and this GPU is plugged into the motherboard inside the "CPU."

The PSU (power supply unit) is where the power plug goes. This PSU is also inside the "CPU" but has a port exposed outside the case. It's has a cable that connects to the motherboard inside the "CPU," and this provides electricity for the motherboard and components connected to it, including the CPU chip.

Where is the CPU Located in a Motherboard?

Normally, even if you open up your computer, you won't be able to see the CPU chip, but you can easily find where it is.

If you see a cooling fan inside your computer on your motherboard, the CPU is underneath it.

This cooling fan is supposed to cool the CPU, which can get very hot, with temperatures up to 100 degrees Celsius (212°F)1.

The temperature of the CPU varies according to how much data the CPU is processing. This is because the data is just electricity going through the CPU: the more data it processes, the more electricity that goes through it, the more electrical energy is converted into heat, so the more hot the CPU gets.

Normally, the CPU's temperature is around 40~50°C. If it gets too hot, the heat damages the CPU. Some CPUs can safely work with temperatures as high as 100°C, but that varies from CPU to CPU. The important thing to note is that CPUs were designed to be cooled. They can't work at their full processing power without a cooler to get rid of the heat.

You shouldn't do this, but if you unscrewed the cooler, underneath it you'd find a door-like panel that keeps your CPU chip locked in place inside of it. If you open this panel, you'll find the CPU chip, and you could remove it.

The CPU chip is much smaller than a RAM chip, but it's also much heavier. You'd be surprised by how much heavy it is. It's like you're holding a solid block of metal.

What are CPUs in the Task Manager?

In the Windows' task manager, and similar software, a CPU is a CPU core, because CPU core is essentially a CPU.

Any time you see "core" it means "processor." So a CPU with 4 cores is a CPU that has 4 processors built inside of it. By the way, GPUs have hundreds of cores, which are also data processors, but that doesn't mean they're more powerful than CPUs, it just means they're designed to handle more data in parallel. Let's understand how this works.

In the past, a single CPU was just a single processor. In other words, it was just a single core. Then we started having dual-core CPUs, and nowadays every CPU is multi-core.

This means that a modern CPU has the power of multiple "old CPUs" built inside of it, they're just called cores instead.

But what does a CPU do, and how does it differ from what a GPU does?

The most important ability of a CPU to execute complex computer algorithms that are encoded as machine code. Every computer program you run in your computer, including your entire operating system, is either a piece of machine code, or a piece of some special code that gets translated into machine code by another program. That's because the only thing the CPU can execute is this machine code, so if it's not machine code, it has to be converted into machine code somehow for it to be executed.

This machine code is very simple in a way, but very complex is another. It's very simple because the idea is that the CPU executes one step of the machine code at a time, so machine code looks like this:

  1. Do this.
  2. Do that.
  3. Do something else.
  4. Do that again.

And all the CPU does is just go step by step executing the commands encoded as machine code.

The complex part is that some steps are jumps. When a CPU encounters a jump, instead of executing the next step, it executes the step specified by the jump. For example:

  1. Jump to step 3.
  2. Say "Goodbye."
  3. Say "Hello world."

In the algorithm above, step 2 is never going to be executed, because the first step always tells the CPU to jump over it. However, if there was a step 4 that said "jump to step 2," then it would be executed when the CPU reached step 4. In fact, in this case, the CPU would go from step 1 to 3, then 4, then jump back to 2, then it would continue to 3 and 4 again, then jump back to 2, then 3, 4, 2, 3, 4, 2, 3, 4, etc. forever. An infinite loop.

The ability to do this is what defines CPUs. In order to do these things, the CPU needs to be able to keep track of which step it's executing, plus any other things that change when the algorithm executes (i.e. state). This is all kept into the computer memory, which the CPU has direct access to.

The algorithm, which step the CPU is at, and other necessary state, is combined into what's called a thread.

In a single-processor CPU, the CPU can only execute one algorithm at a time. Since an algorithm is a computer program, this means the CPU can't execute two programs simultaneously. Similarly, if your CPU has 16 cores, it can't execute more than 16 programs at the same time.

However, you may have noticed that you normally have way more than 16 programs running at once, at least that's what the task manager will tell you, showing a very, very long list of processes running in your computer. How is this possible, if your CPU can't execute more than 16 algorithms at once?

Essentially, what the CPU does is that it has a larger, "super-program," that decides which program to execute at a time, and for how long. This super-program is called a scheduler, and it's part of the operating system's kernel. Every time you want to run a program, instead of simply executing the algorithm, the program is added to a list of programs that are supposed to be running, and then the CPU works on that program a bit, then switches to the next program on the list of running programs, and the next, and the next, and then does it all over again.

Because it switches from one program to another so quickly, it looks like they are all executing at the same time, however, they are not.

For example, when you move your mouse, a program needs to be executed to change the position of your cursor on the screen, and then a separate program executes to actually display the cursor on that new position, and then if the cursor is on top of a button another program has to run to highlight that button. These three programs are likely to be executed one after the other, but it happens so quickly all of this happens before the image data to be displayed on screen is sent to your graphics card to be sent to your monitor, so to you it looks like it all happened at once.

Having multiple CPU cores means that two threads can actually be executed at the same time, one by each processor.

References

  1. https://community.intel.com/t5/Processors/i9-14900K-temperatures/td-p/1540728 (accessed 2024-05-23) ↩︎

Comments

Leave a Reply

Leave your thoughts! Required fields are marked *