How Your OS Runs Applications

When you use your computer—whether for browsing, gaming, coding, or anything else—everything ultimately comes down to calculations and instructions being carried out. The part that does all the actual calculations and follows every single instruction is the Central Processing Unit, or CPU. You can think of the CPU as the entire brain chip of your computer, tirelessly handling every task.
CPU
Cores: Workers of CPU
Inside this CPU chip, there are typically multiple independent working units called cores. Each core is like an independent worker. The crucial point is that each individual CPU core can execute instructions from only one single task at any given instant. Even if a core is incredibly fast, it processes one instruction after another, one at a time.
So, a CPU with four cores can perform four distinct sets of instructions simultaneously, one on each core.
Generally, in most modern personal computers you'd buy today – like laptops or desktop PCs – you'll commonly find CPUs with 4 to 8 cores. High-end consumer computers or specialized workstations might have 10, 12, or even 16 cores. Servers, which are powerful computers designed for heavy tasks, can have many more, sometimes 32, 64, or even hundreds of cores across multiple CPU chips.
Registers: CPU's Own Memory
Each CPU core also has its own very small, super-fast storage areas right inside it, called CPU Registers. When a core is actively working on instructions, it uses these registers to hold the numbers and pieces of information it needs right at that exact moment. They are the fastest place for the core to access data it's currently manipulating.
32-bit vs 64-bit Architecture
When we talk about 32-bit and 64-bit CPUs, we are referring to a fundamental aspect of their design/architecture: the size of the data chunks a CPU core can process in a single operation.
Performance wise, a 64-bit processor can be faster than a 32-bit one, for applications that require large memory or deal with large data types. As an example, if you add two large numbers that require 64 bits to represent, a 64-bit CPU can do that in a single operation. A 32-bit CPU, on the other hand, would need to break down a 64-bit number into two 32-bit pieces and perform multiple operations to achieve the same result, making it slower for such tasks.
Impact of CPU Architecture on RAM
Another benefit of increased bit capacity is the amount of memory a CPU can utilize. Imagine your computer's main memory (RAM) as a vast collection of tiny memory boxes, and each box has a unique "address".
A 32-bit CPU uses 32 digital bits (which are 0s or 1s) to create these memory addresses. With 32 bits, you can create exactly 2^32 unique addresses. If each address refers to one byte of memory, then 2^32 bytes is approximately 4 Gigabytes (GB). This means a 32-bit CPU can only directly "point to" or use a maximum of about 4 GB of your computer's main memory. Even if you install more than 4 GB of RAM, a 32-bit CPU cannot physically address or utilize that extra memory beyond its 4 GB limit.
However, a 64-bit CPU uses 64 bits to create memory addresses. This allows for an astronomically larger number of unique addresses – 2^64. This vastly expanded addressing capability means a 64-bit CPU has the capacity to use a huge amount of RAM, easily reaching into Terabytes (TB) of RAM and beyond, limited mainly by how much RAM you can provide as hardware. This capability is essential for modern software, which often requires significant amounts of memory to run efficiently.
With this understanding of what the CPU can do, let’s look at how the software—particularly the operating system—takes advantage of it.
Operating System (OS): The Coordinator
The Operating System is a very special, complex program, a piece of software, that acts as the coordinator of your entire computer system. It is crucial to understand that the OS is a software, while the CPU is a hardware. They are distinct but work very closely together.
The OS is responsible for controlling and coordinating all the hardware components (including the CPU and its cores, input devices like keyboards, output devices like screens) and all the other software programs you run. It acts as the bridge between you, your programs, and the computer's hardware. One of its key roles is directly managing the cores of the CPU. The OS tells each individual CPU core what instructions to execute and when.
Multitasking: Time-Sharing and Context Switching
In the very early days of computers, only one program could run at a time. You had to finish one task before starting another. The ability to run multiple programs seemingly at once, called multitasking, was a major advancement implemented by the OS.
The OS achieves multitasking through a technique called time-sharing. A key part, known as the OS scheduler, is responsible for this. The scheduler doesn't let one program run continuously. Instead, it gives each running program's active worker (a "thread," which we'll discuss next) a very small slice of CPU time on a core.
After that tiny slice of time, the OS takes control back from that thread and then gives the CPU core to another thread for its own small slice of time, and so on. This switching happens incredibly fast, often thousands or millions of times per second. Because of this rapid switching, it creates the illusion that all programs are running simultaneously, even if your computer only has one CPU core.
How does the OS manage to take control back from a running program? It uses hardware mechanisms called interrupts. When a CPU core receives an interrupt or even when a thread voluntarily yields control, it immediately stops what it's currently doing and temporarily hands control over to the OS. This allows the OS to regain control from the running thread, even if that thread is very busy. Once the OS has control, its scheduler can then decide which thread gets to run next on that CPU core. This entire process of pausing one thread and starting another, including saving and loading their states, is called context switching.
Processes and Threads
A process is an isolated environment for a running program, created and managed by the OS. It includes dedicated memory, file access, network permissions, and more.
When you open any program on your computer, the OS creates a process for it. It also assigns and manages all the resources a process needs, such as its dedicated segment of memory, access to specific files on the hard drive, and network connections, and prepares it for execution. When you close the program, the OS cleans up and removes its process, freeing up all its resources.
The OS uses special hardware capabilities to enforce strict boundaries between processes. This means one process cannot directly read from or write to the memory space of another process without explicit permission from the OS. This isolation is fundamental for system stability and security; if one program crashes, its issues are contained within its own process, preventing it from corrupting or crashing other running programs or the entire operating system.
Inside each program (process), there can be one or many threads. A thread is a smaller, individual sequence of instructions or a specific "worker" within a process. All threads within the same process share that process's allocated memory space and resources. This makes them very efficient for tasks that need to cooperate closely and share data within one program. The OS is also responsible for creating, destroying, and managing these threads within their respective processes.
It is crucial to understand that processes and threads are concepts and structures created and managed entirely by the Operating System. They are not inherent features of the CPU hardware itself. The CPU simply executes the instructions that the OS tells it to run, which come from threads.
How Processes, Threads, and Cores Work Together
Let’s make the relationship clear:
Only one thread runs on a single CPU core at any given instant. This is a fundamental rule. A CPU core can execute instructions from only one thread at a time. The OS scheduler assigns a thread to a specific CPU core to execute its instructions. The OS tells a core, "Now, execute instructions from this thread."
A thread does not always run on the same core. When a thread is paused (during a context switch) and then later resumed, the OS scheduler can (and often does, for load balancing) choose to run that thread on any available CPU core, not necessarily the same one it was on before. This flexibility helps the OS efficiently manage the workload across all cores.
During context switching, the complete state of the thread being paused is saved. This includes all the values currently held in the CPU's registers for that thread, the exact instruction it was about to execute next (its program counter), and any other crucial information about its current progress. This entire state is copied from the CPU's registers and stored into a specific memory area designated for that thread, which resides in the computer's RAM. When the OS decides to resume that thread later, it retrieves this saved state from RAM and loads it back into the CPU's registers, allowing the thread to continue executing precisely from where it left off.
And multiple threads of the same process can run on different cores simultaneously. This is a key benefit of multi-core CPUs. If your program (process) has multiple threads, the OS scheduler can distribute those threads across different available CPU cores. This allows different parts of your single program to genuinely execute at the same moment, speeding up its overall performance.
This is how modern applications take full advantage of multi-core CPUs. Threads allow programs to scale their workload, and the OS ensures they are efficiently distributed across available cores.
Concurrency and Parallelism
Now that we understand cores, threads, and the OS's role, it's important to define two often-confused concepts, concurrency and parallelism:
Concurrency is about the ability of the OS to manage and make progress on many tasks over time, even if there are not enough CPU cores to execute them all at the exact same instant. It relies on time-sharing and rapid context switches between various threads, creating the illusion of simultaneous execution. This is possible on any computer, even those with only one CPU core.
Parallelism is about the actually doing of multiple tasks at the exact same moment. This is achieved when the OS schedules different threads to run on different, available CPU cores. So, if you have a 4-core CPU, the OS can run up to four distinct threads truly in parallel. This is possible only if you have a multi-core CPU.
Modern systems combine both: they use concurrency to manage more tasks than available cores, and parallelism to speed up those tasks on multicore hardware.
Example: Running Multiple Tabs on a Browser
Let’s make this all even more tangible by walking through a real-world scenario: opening multiple tabs in a web browser.
When you launch your web browser, say Chrome, the Operating System creates a process for it. This process includes everything the browser needs: memory to hold the pages you view, access to the network for loading websites, and access to files for caching or downloads.
Now, when you open multiple tabs within that browser, the architecture becomes more layered:
Each tab is often handled by a separate process (or at least a separate thread, depending on the browser's internal design). For example, Chrome is well known for creating a separate process per tab. This isolation means that if one tab crashes due to a faulty script, it doesn’t take down other tabs or the entire browser—because the OS has enforced process-level isolation.
Within each browser process or tab, there are multiple threads. For instance, one thread may handle rendering the web page (graphics), another may handle JavaScript execution, while another manages network communication. All these threads share the same memory and work closely together, allowing the web page to load smoothly and respond to user interactions.
The OS scheduler assigns these threads to CPU cores. If your computer has four cores, four threads—possibly from four different tabs or background tasks—can run truly in parallel. If there are more threads than cores (which is usually the case), the scheduler uses time-sharing to rapidly switch threads in and out of each core.
Context switching ensures that if you're watching a video in one tab, loading another page in a second tab, and downloading a file in the background, your system appears responsive—even if those operations are switching in and out of a single core every few milliseconds.
Conclusion
Understanding this coordination between the CPU, its cores, the OS, processes, and threads is crucial to understand how your computer gets work done. Whether you're writing code, using software, or just curious about how things work, this is how it's done.




