Skip to main content

Command Palette

Search for a command to run...

OS Development and Computer Architecture: My Journey from Web-development to Understanding the Machine-part-1

Updated
9 min read
OS Development and Computer Architecture: My Journey from Web-development to Understanding the Machine-part-1
A
I write on a mix of backend and frontend, which usually covers technologies like mongoose, react, express and etc.

What is an architecture?

Well I am sure you might have heard of CPU(Central Processing Unit) before too, and it isn't hard to learn of course the architecture at first might seem complex but once you understand- it is simpler than anything. Let's jump right into the architecture without any verbose intro!

A computer architecture is like a language that CPU understands.Programs written in C, Rust or any other programming language are eventually translated into machine instructions that matches a specific architecture. If simply said, a French speaker won't understand english and an English speaker vice versa . Like that every computer understands a different language which is nothing but defined and classified by an architecture. There are different types of architectures right there. Which we will understand in the next para.

Some commonly used and classified architectures are as below:-

  • x86 architecture - Used by early intel chips(Starting with 8086), as they ended in 86 this was named x86 architecture which is used to describe 32-bit CPUs and operating systems.

  • x64 architecture - This is known as x86-64, this is simply the 64-bit extension of the original x86 architecture. This is the architecture that is used by modern computers and operating systems.

  • ARM architecture(Advanced RISC Machine) - This is made to be power-efficient. making it the industry standard for smartphones, tablets, wearable tech. While x86 focuses on raw, complex power, ARM focuses on doing simpler tasks extremely fast using minimal electricity.

Well many panic here but you don't need to! We will understand every architecture one by one and why we even need different architectures. To understand each of them first we must deeply understand the Instruction Set Architecture(ISA) of CPU and how does it actually works?

What is an Instruction Set Architecture?

Okay, so the first question is what problem was caused that we needed to invent this? To find the answer we need to go deep in the history of early computers where humans were required to physically rewire circuits or write machine code(1s and 0s) to perform tasks. Extremly complex right? This caused computer scientist to make a standardization of these low level machine instructions. Which is called as Instruction Set Architecture(ISA). ISA introduces standardized commands (like ADD, LOAD, STORE, allowing complex human instructions to be translated into intructions which could be understood by machine.

If we don't use the Instruction Set Architecture, we would have to write code bounded to hardware and when the company would feel upgrading it's computers/servers engineers would have to rewrite the whole software for that specific hardware!

This is why we need the Instruction Set Architecture, this makes our life very easy to write code which could be understood by both machines and humans.

Understanding CPU's working :-

Now as we understand the working of Instruction set architecture we can move on to discuss about how CPU executes them(instructions). The diagram below shows some simple components of CPU, let's get straight into understanding them!

  • Input unit - The input unit is responsible for receiving the data from your computer and sending it to the computer for processing.Example include- keyboard strokes, mouse, Microphone and all other type of inputs.

  • Output unit - The output information is reponsible for presenting the proccessed data back to the user. Exmaple include- Monitor, Printers, Speakers and etc.

  • Memory unit - The Memory Unit stores data and instructions that are currently being used by the CPU. Think of it as computer's notebook. For example- "x = 5", "y = 3 ", These are stored in memory unit before processing.

  • Registers - Registers are a part of memory unit, they are faster to access compared to RAM but provide very tiny space that could be used to store integers or strings. They are inetegrated into the CPU itself. This is the reason they are super fast to access.

  • Arithmetic Logic Unit(ALU) - The Arithmetic Logic Unit, or ALU, is the part of the CPU that performs calculations and logical operations. Example- " 5 + 3", "2 * 4" and etc.

  • Control Unit(CU) - While the ALU performs calculations, the Control Unit coordinates all activities inside the computer. Its responsibilities include:

  • Fetching instructions from memory

  • Decoding what those instrcutions mean

  • Directing the data to the correct components

  • Controling the executions of the instrcutions


Understanding architectures deeply-

Now as we know about major componets of the computer and understand how they work together in order to complete a task. We can now look at different types of architecture that we discussed earlier more precise and deeply.

Although every processor contains components such as the Control Unit, ALU, and Memory Unit, not all processors speak the same language.

This language is defined by the processor's architecture and Instruction Set Architecture (ISA). Think of it as Humans communicate using languages like English, French, Spanish and etc and computers communicate using instruction sets like x86, x64, ARM and RISC-V.

Each architecture has its own way of representing instructions, managing memory, and processing data.


x86 Architecture

The x86 architecture originated with Intel's 8086 processor and became one of the most successful architectures in computing history.

x86 is a 32-bit architecture, meaning its registers and memory addresses are primarily 32 bits wide.

A simple x86 instrcution looks like this:

mov eax, 5 
add eax, 3

Here:

  • mov place the 5 into EAX register

  • add 3 to the value already stored in the register

One characteristic of x86 is that it belongs to the CISC (Complex Instruction Set Computer) family.

This means a single instruction can often perform multiple operations.

x64 Architecture

As computers became more powerful, the limitations of 32-bit system became apparent.

To solve this problem, AMD introduced x86-64 (commonly called x64), which extended x86 to support 64-bit processing.

A similar instruction in x64 looks like:

mov rax, 5
add rax, 3

Notice the register name changed:

The larger registers allow the processor to work with larger numbers and access significantly more memory.

This is why modern operating systems such as Windows 11, Linux, and macOS primarily use x64 processors.

ARM Architecture

ARM follows a different philosophy.

Instead of creating highly complex instructions, ARM focuses on using simpler instructions that can be executed efficiently.

MOV X0, #5
ADD X0, X0, #3

ARM processors are extremely power-efficient, making them ideal for:

  • Smartphones

  • Tablets

  • Smartwatches

  • Embedded devices

  • Modern Apple Slicon computers

This is one reason your smartphone can run for many hours on battery power.


Why don't we use only one architecture?

Now after understanding all of this, a question arises- If all architectures perform the same tasks, why do we need different ones?

The asnwer lies in trade-offs

Architecture Strength
x86 Backward compatibility
x64 High performance and memory support
ARM Power efficiency

Different devices have different requirements.

A smartphone prioritizes battery life.

A gaming PC prioritizes performance.

An embedded sensor prioritizes low power consumption and cost.

As a result, different architectures evolved to solve different problems.


Why This Matters for OS Development-

When developing an operating system, the architecture determines:

  • Which instructions can be executed

  • How memory is addressed

  • How interrupts work

  • How the CPU starts after power-on

  • How bootloaders are written

For example, the Stage 1 and Stage 2 bootloaders shown later in this article are written specifically for the x86 architecture. An ARM processor would not understand these instructions because it speaks a completely different instruction language.

This is why understanding computer architecture is one of the most important skills in operating-system development.


What Happens When You Press the Power Button?

Well have you every thought what magic happens when we click the power button on a computer? How do we get directly to the Dekstop? The answer to this is that there isn't any magic behind it but ton of techinal work that your operating system does in order to keep your machine working and stable.Let's see the actual technical work behind the computer turning ON.

  • POST(Power-on-self-test)request - When you press the power button , the motherboard sends a signal to the power supply. Once the stable power is confirmed, the CPU is rest and it fetches the intructions from the BIOS/UEFI chip. It check the hardware by running a POST(Power-on-self-test) before booting a opearating. This has nothing to do with the http post request.

  • CPU Boot - The CPU begins execution from a predefined memory location called the reset vector. This location contains firmware instructions stored in the BIOS or UEFI chip, allowing the system to begin the boot process.

  • Bootloader- The frimware finds raw bootable drive after this and then executes it bootloader, loads the kernel into the RAM, initializes core system services and finally lanunces the user interface or the login screen.


    The END

It was 4 months ago when I started doing web-dev with frontend and backend, I enjoyed doing the high-level stuff but after doing the web-dev I always wondered how do computers work at very low level? How does os works? How to make one?

This curosity eventually led me to go deep into the computer architecture, os-dev and low level programming with C and assembly. At first it was complex but eventually all of this started making sense and I got a deep admiration for the computers and there working. I hope you founded this interesting and engaging.

Well, this isn't the end I still have a lot more to write about the OS-development and working which I will cover in part-2 of this series. Be with me if you like! Don't worry we will explore more about the operating systems in part-2

10 views