Understanding The Operating System - The Brain Behind Your Computer
What is an Operating system An operating system (OS) acts as a resource manager, where 'resources' refer to computer hardware such as the CPU, RAM, disk storage, and I/O devices. It simplifies program execution by allocating memory and facilitating communication between software and hardware. In reality, a computer has only one set of these physical resources yet hundreds of programs rely on them simultaneously. The OS efficiently distributes these resources among all running applications. Additionally, the operating system ensures smooth and effective performance through three key functions: i. Virtualization ii. Concurrency iii. Persistence Virtualization: The Art Of Creating Illusions Imagine you have a single apple but need to share it among five children at the same time. To make this work, you create a visual copy of the apple for each child. Now, all five happily believe they’re eating their own apple unaware of the illusion. In computing terms: The apple represents a single core CPU (or any physical resource like memory). The children are programs demanding simultaneous processing. The visual copies are virtualized resources. Example - CPU virtualization const process = require("process") function virtualizationExample(){ for(let i = 0; i < 5; i++){ console.log(`PID- ${process.pid} ${i}` ) } } virtualizationExample() in our terminal, run the command node visual.js & node visual.js & node visual.js & node visual.js the following will be displayed in the terminal macbook@Gabriella-Macbook tt % node visual.js & node visual.js & node visual.js & node visual.js [1] 10125 [2] 10126 [3] 10127 PID- 10126 0 PID- 10128 0 PID- 10125 0 PID- 10127 0 PID- 10126 1 PID- 10127 1 PID- 10125 1 PID- 10126 2 PID- 10127 2 PID- 10125 2 PID- 10126 3 PID- 10127 3 PID- 10126 4 PID- 10125 3 PID- 10127 4 PID- 10125 4 PID- 10128 1 PID- 10128 2 PID- 10128 3 PID- 10128 4 [1] done node visual.js [3] + done node visual.js [2] + done node visual.js An interesting insight to see. even though we only have one CPU, our system still manages to run 4 programmes at once and we can see a mix of process id's from each of the diffrent process - (A process is a running program) How does this work? The operating system employs clever scheduling policies to rapidly switch between processes, creating the seamless illusion of parallelism. (We’ll dive deeper into these policies in a future article!) Concurrency: The Art of Juggling Processes Let’s revisit our apple analogy. When we created virtual instances of the apple for each child, it seemed like every child had their own apple. But in reality, we were quickly passing a single apple between them—so fast that no one noticed the switch. In computing terms, this is exactly how the operating system handles multiple processes on a single CPU. For example, when you run four instances of a program, the OS rapidly cycles between them allocating resources to PID-10126, then PID-10128, then PID-10125, and so on. This lightning fast switching happens in milliseconds and is called context switching. It’s the magic behind the illusion that your computer is running dozens of programs simultaneously, even with just one CPU core. Persistence: How Data Survives Power Off In systems, memory is volatile especially memory associated with a running program (process). when our system is abruptly shut down or turned off, all the data stored in the memory of the process is lost and so, our system need a means to store data persistently. In modern systems, a hard drive (HDD - Hard Disk Drive) or an SSD (Solid State Drive) is used to store data permanently. The software in the operating system that manages how data is stored on the disk is called the File System. it handles storage and easy retrieval of files in an efficient manner. Unlike the CPU and Memory, The Operating system does not create a virtualized form of the disk storage. In a Nodejs context, whenever we use the fs library, system calls are routed to the file system of the operating system. The operating system sends I/O request to the storage device through the device driver - (A code in the operating system that deals with the operation of a device in a system) in order to figure out where this new data will be stored in the file system and ensures it keeps track of the structure currently maintained in the file system. Summary In this article we covered the major functionality of the operating system and how it accomplishes it. we started with virtualization - how the operating system creates an illusion of abundant resources and how it uses concurrency to share this single resource among running programs and how it ensures persistency of data using the file system. Together, these three pillars enable your computer to run smoothly, efficiently, and reliably. Thank you reaching this far!. Dont forget to like ❤️, shar

What is an Operating system
An operating system (OS) acts as a resource manager, where 'resources' refer to computer hardware such as the CPU, RAM, disk storage, and I/O devices. It simplifies program execution by allocating memory and facilitating communication between software and hardware. In reality, a computer has only one set of these physical resources yet hundreds of programs rely on them simultaneously. The OS efficiently distributes these resources among all running applications.
Additionally, the operating system ensures smooth and effective performance through three key functions:
i. Virtualization
ii. Concurrency
iii. Persistence
Virtualization: The Art Of Creating Illusions
Imagine you have a single apple but need to share it among five children at the same time. To make this work, you create a visual copy of the apple for each child. Now, all five happily believe they’re eating their own apple unaware of the illusion.
In computing terms:
The apple represents a single core CPU (or any physical resource like memory).
The children are programs demanding simultaneous processing.
The visual copies are virtualized resources.
Example - CPU virtualization
const process = require("process")
function virtualizationExample(){
for(let i = 0; i < 5; i++){
console.log(`PID- ${process.pid} ${i}` )
}
}
virtualizationExample()
in our terminal, run the command
node visual.js & node visual.js & node visual.js & node visual.js
the following will be displayed in the terminal
macbook@Gabriella-Macbook tt % node visual.js & node visual.js & node visual.js & node visual.js
[1] 10125
[2] 10126
[3] 10127
PID- 10126 0
PID- 10128 0
PID- 10125 0
PID- 10127 0
PID- 10126 1
PID- 10127 1
PID- 10125 1
PID- 10126 2
PID- 10127 2
PID- 10125 2
PID- 10126 3
PID- 10127 3
PID- 10126 4
PID- 10125 3
PID- 10127 4
PID- 10125 4
PID- 10128 1
PID- 10128 2
PID- 10128 3
PID- 10128 4
[1] done node visual.js
[3] + done node visual.js
[2] + done node visual.js
An interesting insight to see. even though we only have one CPU, our system still manages to run 4 programmes at once and we can see a mix of process id's from each of the diffrent process - (A process is a running program)
How does this work? The operating system employs clever scheduling policies to rapidly switch between processes, creating the seamless illusion of parallelism. (We’ll dive deeper into these policies in a future article!)
Concurrency: The Art of Juggling Processes
Let’s revisit our apple analogy. When we created virtual instances of the apple for each child, it seemed like every child had their own apple. But in reality, we were quickly passing a single apple between them—so fast that no one noticed the switch.
In computing terms, this is exactly how the operating system handles multiple processes on a single CPU. For example, when you run four instances of a program, the OS rapidly cycles between them allocating resources to PID-10126, then PID-10128, then PID-10125, and so on.
This lightning fast switching happens in milliseconds and is called context switching. It’s the magic behind the illusion that your computer is running dozens of programs simultaneously, even with just one CPU core.
Persistence: How Data Survives Power Off
In systems, memory is volatile especially memory associated with a running program (process). when our system is abruptly shut down or turned off, all the data stored in the memory of the process is lost and so, our system need a means to store data persistently.
In modern systems, a hard drive (HDD - Hard Disk Drive) or an SSD (Solid State Drive) is used to store data permanently.
The software in the operating system that manages how data is stored on the disk is called the File System. it handles storage and easy retrieval of files in an efficient manner.
Unlike the CPU and Memory, The Operating system does not create a virtualized form of the disk storage.
In a Nodejs context, whenever we use the fs
library, system calls are routed to the file system of the operating system.
The operating system sends I/O request to the storage device through the device driver - (A code in the operating system that deals with the operation of a device in a system) in order to figure out where this new data will be stored in the file system and ensures it keeps track of the structure currently maintained in the file system.
Summary
In this article we covered the major functionality of the operating system and how it accomplishes it. we started with virtualization - how the operating system creates an illusion of abundant resources and how it uses concurrency to share this single resource among running programs and how it ensures persistency of data using the file system.
Together, these three pillars enable your computer to run smoothly, efficiently, and reliably.
Thank you reaching this far!. Dont forget to like ❤️, share