The power button
Tags: hardware, os, curiosity
Published: 2023-07-13 08:02:29

Have you wondered what happens when we press the power button on our computer ? How does a computer begins in an off state and then be in an active state in 15 seconds ? It would be amazing  to know every step a computer takes to be turned on and be fully functional.

That’s what I am going to be researching today. 

<aside>
💡 What exactly happens when you press the power button on your PC ?

</aside>

- To understand the whole process let’s divide it into subtopics.

### 1. **Power**

Every component of our computer needs electricity to operate. So, for this purpose there is a component called Power Supply that handles this process. It receives power from a DC, AC or if we have a laptop our battery will do the same thing. They distribute the power among the components of the PC. Here the power that is being distributed is going to be checked whether its the right amount or not. After everything got power the CPU tries to load a program called BIOS which is found in ROM.

### 2. **ROM, POST and BIOS**

- let’s see each of them separately
    
    **I. ROM**
    
    ROM is an abbreviation of Read Only Memory, when we were learning about it I didn’t get what its used for until now. When I am learning I like to relate new things with the things I know before. But for this one I couldn’t relate it at all.
    
    So related to our topic, what ROM is used for is to store this program we called BIOS earlier. Since its read only memory its contents will be there anytime and cant be overwritten. 
    
    Additionally it is hardwired in the motherboard and it comes loaded with the BIOS which the manufacturers of the motherboard will be responsible for.
    
    **II. BIOS**
    
    BIOS stands for **Basic Input Output System.** So, this piece of software is stored on a small memory chip (the ROM as I mentioned before).
    
    We can say BIOS is the first software to run after we press that power button. But what is its use in the process that we are talking now ? 
    
    It contains a set of instructions waiting to be executed once we press that power button. The first instruction to be executed is called POST. And it loads configuration settings from a special place called CMOS battery ( It is here that your clock is ticking by the way).  
    
    **III. POST**
    
    POST stands for **Power On Self Test.** What this thing basically do is check all the components(RAM, Hard drive and other Input Output devices ) in the motherboard ****whether they are working correctly or not. This is because its at this point we have to know if something is not working among the components. Here if there is a failure, it will tell us using different kinds of beep sounds. And like the morse code these beep sounds have their own meaning, maybe you encounter them before.
    
    It achieves this checking stage by sending signals using the System Bus to the components. So, if all the components are functioning normally the next step begins. Here let’s talk about BIOS a little bit. 
    
    The BIOS is currently in control of everything at this point, so after the POST is over it grants the CPU to have access to all the hardware components that are connected to the motherboard. Hence, the CPU tries to access a startup code which is usually (There is a reason I said usually but that is for another article.) found in the **hard drive.** This startup code is called **The Boot Code.**  
    
    Now that all the hardware are operating in our motherboard, the next step will be booting up the software.
    

### 3. **The Boot Code**

So, before we talk about the **Boot Code** we have to have a base knowledge about the **MBR**. What is MBR ??

First **MBR** stands for **Master Boot Record**. It is a small piece of code responsible for loading the OS on your computer. It also contains information about the partitions on your hard drive and how they lay out.

We said BIOS is found in a ROM chip which is hardwired in the motherboard if you remember,  so where ****is the MBR located ?? 

The MBR is located in the **first sector of your hard drive** which is S**ector 0**. (If you are wondering what sector is, I got you. Sector is the smallest physical storage unit of a hard drive and it is fixed to store 512 bytes of data.) 


![The disk anatomy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qnw2yejwbmhaaaado4wv.png)

Now let’s continue where we left off. We stopped when the CPU tries to access this Boot Code which is found in the hard drive. Actually this Boot Code is not found alone. That’s why I tried to explain what MBR is. It turns out **Boot Code ( 446 bytes )** is one of the three main parts of the MBR. The other two parts are **The partition table ( 64 bytes )** and **The MBR signature ( 2 bytes)**.

We now know what a Boot Code and MBR are, so we can proceed to the next step. The next step will be the CPU loading this MBR to the memory ( RAM ) to run it. Here, after the CPU runs the Boot Code it will try to find where the installed OS is found in the partitions of our hard drive. 

Once it find the OS files it will load them to RAM to run them. And then the OS will take control of the system starting from now. At this point the OS will tell the CPU to run a bunch of background services and device drivers which will run in the background these background services include: 

- Windows services (If you are using windows)
- Different processes
- Desktop environments

 Finally, you will be asked to enter your password. Voila your PC booted up successfully !!

If you are still here it means you are curios enough to continue . . . These are the resources I used to write this. 

- **Resources**

[What happens when I turn my computer on?](https://youtu.be/C_xxra5HMz0)

[What happens when you turn on a computer](https://www.youtube.com/watch?v=B8_oQ3cU5FI&t=728s)

[WHAT HAPPENS WHEN YOU PRESS COMPUTERS POWER BUTTON!!!!!!](https://www.youtube.com/watch?v=HzbpT67S1jo)

[What Exactly happens when you press the power button on PC ?](https://medium.com/@Ayushverma8/what-exactly-happens-when-you-press-the-power-button-on-pc-7c781050b83e)

[What Exactly Happens When You Turn On Your Computer?](https://www.howtogeek.com/398493/what-exactly-happens-when-you-turn-on-your-computer/)

[What Happens When You Press the Power Button? - AMI](https://www.ami.com/blog/2018/02/05/what-happens-when-you-press-the-power-button/)

[What happens when you turn on the computer |Computer Fundamentals |Computer course |computer science](https://youtu.be/3KcpWxbhzr8)

[An Ultimate Guide to the Master Boot Record (MBR)](https://www.easeus.com/diskmanager/master-boot-record.html)