Disclaimer: This is my interpretation of the concepts in computer and networking the way I understand it. Everyone has a different understanding of the topics, and how everyone sees something could be different; I am just showing this from my perspective. Of course, what I understood could very well be misinformed or totally wrong. Please do not treat what you see here as fact and always do your own research. These should be for entertainment and comedic purposes only 😉. Enjoy!
Welcome back to Noob 101. Today is another fine day, and as always, I’m Prof. Laz, and we will be talking about the component of a PC that everyone has heard of, the central processing unit or CPU. Today’s lesson will be a brief overview of the fundamental of what it does and how it works.
Here is a short breakdown of today lecture:
- What is a central processing unit (CPU)
- How does it work?
- Different types of architecture
- What is cores/thread and gigahertz mean for CPU?
What is a central processing unit?
As you already know, the central processing unit or CPU is a crucial component of every electronic device. It was in charge of performing specific functions that the devices were designed to do. I’m sure everyone is familiar with a hand-calculator; it too has a chip in charge of taking the inputs you provide, doing the calculations for you, and displaying the output on the screen to get the answer. One could say, if we compare a computer to a human, then the CPU is the brain because it is in charge of processing the information passed along by the nervous system and produces the output. So fundamentally, every electronic that required the processing of information/data (or inputs) required a brain to produce outputs hence why we called it a central processing unit. The CPU in the computer is more generalized as it can do a lot of tasks and do it well. It connects the inputs to the components of the output.
How does it work?
So how does it achieve this manner? One word: Magic! 😛. Just kidding, though it might as well be since somehow we managed to create something so complex with fundamental concepts. Do you recall what I say back in the lesson about binary? How can a computer do math using logic gates? Well, this is where the logic gates are? CPU is comprised of billions of transistors (or more). What are transistors, you ask? They are a type of semiconductor, meaning they can either allow the electricity to flow through or stop the flow of electricity, basically a switch. What makes it powerful is that this switch is fully controllable on how we want it to behave. We are using this to implement the logic gates and do the calculations with them. So when we are doing anything, we are essentially giving the CPU a set of instructions and telling it to do it and give us the result. We can use the results as is or for another calculation. Everything is built on top of one another. For example, we want to know what is 1+1+2. We must first have them as the input and in binary form (since the computer only understands binary) and do the addition operation for 1+1. We get 2 as a result and then feedback into the input and do another addition operation of 2+2. We have 4 as the final output (in binary). Of course, this process can be done in nanoseconds, so you probably wouldn’t even realize that it was doing anything before giving you the answer 😂. In case you are not too sure what the prefix is, nano is one billionth of a second. So yes, it is very fast.
Different types of architecture
Since we are only talking about CPU in the general computer sense, I will exclude the integrated circuit chips in extending Field-Programing gate array (FPGA) and Application-specific integrated circuit (ASIC). They are all technically processors and perform the same functions, but they focus on a particular field like a family doctor and some specialists. Apology to go off the tangent. Let go back to the CPU architecture, shall we?
When I talk about architecture, I’m mean about how a modern CPU is designed. They are using the same fundamental principle, but there are different ways of implementing; thus, there are some differences in terms of performance. The two notitable archertechual for modern CPU are x86 and ARM. If you don’t know what they are, it is totally fine. Currently, most of the consumer CPUs are based on x86 architecture, and there are 2 most prominent players in the field that hold the licenses for this. I’m sure you have heard of them: Intel and AMD. ARM is relatively new in a desktop computer. Still, most mobile phones and internet of things (IoT) devices are dominated by ARM as their CPU of choice due to their energy efficiency advantage. However, ARM is going to make tremendous progress and start to move into the PC market with Apple using it for their Macbook.
What is core/thread and gigahertz mean for CPU?
I’m sure you have heard about cores, thread, and gigahertz when people talk about CPU, but you probably have no idea what they meant. Worry not; it was not that complicated (maybe a little). So the primary function of a CPU is to perform a function, correct? It has to take place somewhere, and that somewhere is the core. So when you ask the CPU to perform a task, 1 core can perform 1 task at a time, just like everyone else (multi-tasker aren’t real, change my mind 😛). So when you hear this CPU has 4 cores, it means the CPU can perform 4 tasks simultaneously. But what happens when a task is finished and it takes some time to load data for another task before the core can perform the instruction? To mitigate the downtime and increase efficiency, we have the thread. Here is the analogy, the core is the factory that requires material (data in this case), the material needs to be loaded from the storage, which is kind of far away. If we only have 1 entrance for the truck to load the material, then we have to wait until the factory finishes processing the material then tell the truck what materials need to be loaded next. The truck will then need to go to the storage, load the material and come back and introduce downtime where the factory just sits there and does nothing while waiting for the truck to come back. But what happens if there is another truck there already with the materials and a different instruction? The factory won’t be working on the work of the first truck’s job, but by the time the first truck comes back, the work of the second truck is almost done, and the factory can continue working without any interruption. That is what the thread does. We can call it a virtual core where we can assign the second instructions so that we cores can continue to work on both without any downtime waiting for the data to be loaded. A clever design, and thus, 2 threads is a good number for 1 core, which is why you usually hear 4 cores 8 threads or 8 cores 16 threads because of this. There is no point in having more than 2 threads per core 😉.
So now you know what is core and thread, what is clock speed we usually hear gigahertz (GHz) then? Hertz is a unit of frequency, and it is to describes how fast something is. I will have a future lesson talking about frequencies to describe more about it. But for short, 1 hertz is how often something happens in 1 second. When you say 10 hertz, this happens 10 times in 1 second. Not too hard to understand, right? If you recall the prefix, I talked about in the bit and byte. Giga means 1 billion times the unit. In this case, 1 billion hertz. I did say the CPU comprises billions of transistors which are like switches. So the frequency for this case shows how fast the switch can flip. If a CPU says the speed is 2 GHz, then the speed of the transistor flip is 2 billion times per second. They are what we call clock speed in a CPU.
Generally, the higher the clock speed, the faster the CPU’s instructions can process. I mean, it makes sense because the faster you can do something, the faster it gets done, right? The only issue with this is the higher the clock speed, the hotter the CPU gets, and we know electronic does not like to be too hot because they will shut down past a certain temperature thread hold to make sure the component is not damaged. This is why we need a CPU cooler😉 but it can’t only help up to a certain amount until it is too much heat to dissipate. The point is to balance the clock speed and heat dissipation to get more performance for the amount of power required. And yes, you need to put more power to increase the clock speed; hence sometimes you hear the term overclocking. That means bringing the clock beyond the usually rated clock speed of the CPU by increasing the power; you will see some performance increase but have to consider the longevity of the component and if you have adequate cooling. Everything is all about balance. Nowadays, though clock speed is still a factor in determining the performance of a CPU, it was not the end all be all like it used to be due to how some change in the CPU’s architecture could help increase the number of instructions done per second. You know what they say, work smarter, not harder, so this is the approach for it.
End of the lecture
Congratulation on finishing another lecture. Thank you for sticking around, and I hope this has been a helpful one for you to understand some of the core concepts in computers. There are plenty of resources out there if you wish to learn more. Of course, if you wish to learn more about the detail, I can put up a few resources, or you google it yourself. What I talked about today is merely the most basic, if not less than that, but at least now you have some idea regarding what a CPU does, and it is still something 😉. Until next time.
-Prof. Laz