Decoding Operating Systems🕵️‍♂️

R.Devansh Shukla
5 min readAug 1, 2023

--

⚠️ Disclaimer: This blog deals with operating system concepts at an abstract level. For a more in-depth understanding, consider referring to handwritten notes or reliable learning resources, such as the Operating System book by John Wiley & Sons.

This blog focuses mainly on Operating System Processes, Services, and Scheduling. Will make sure to post a sequel blog including File and Memory management.

Why Operating Systems Came Into Existence: 🖥️

When the Systems and devices were getting equipped with subterfuge Peripherals and were being commercialized, A need to make the System more user-oriented soon became a product of engagement and luxury.

The notion “the operating system should have a better user experience” sparked operating system optimisation, which in modern times has become commonplace.a point where Apple Inc.’s Mac Book is well known for its user interface and is regarded as a productivity booster.

Would Suggest Figjam for Architecture diagrams, Personal Suggestion

A system that can utilise these processors effectively needed to be built as they got more power-hungry and deployable; as a result, an operating system — a system that can manage files, Memory, disc, and Peripherals — was required.

Main Concepts: 📚 This blog will explore various operating system concepts with the aid of a single reference (considering a web browser as an example).

  1. Different Processing Environments.
  2. IPC, DMA, ISR, Hz & Jiffies, Micro Kernel, API & ABI.
  3. System Calls, Process Scheduling ( FCFS, RR, SRT ).

Different Processing Environments.

  • Single Processor System.

The web browser process will be completed and scheduled with fair use of CPU time and Memory( L1, L2 cache ).

  • Multi-Processor System.

The global scheduler takes into account factors like the process priority, process state (running, ready, waiting), CPU affinity (preferential assignment of processes to specific CPUs), and the current workload of each processor. It then determines which process should run on which processor. The goal is to balance the load across all processors to ensure that they are being utilized efficiently. 🤫Uses MESI Protocol for coherence.

  • Distributed Systems.

Data is replicated across multiple nodes for fault tolerance and load balancing purposes.

Continuing with the multi-processor system, The process (Web Browser) is running on one of the processors and the web browser has to fetch a file from the file explorer( A new process ), The new process is created and scheduled with the help of a global scheduler. But how can two independent processes communicate with each other ???

Inter-Process Communication (IPC): 📩

The 2 processes can communicate with each other ie...The web browser can access the file without any interference from the processor and making the CPU time efficient.

  • Pipes / FIFOs.
  • Sockets { Gmail — Socket Connection — Server }.
  • RPC { Remote Process Calls > Call function residing in different spaces as if they were local }.
  • Semaphores.

A new process ( File operation ) > The web browser reads the file's data, This will not be going till the processor level instead the file operation is done with the help of the File system and kernel, TheInterrupt Service Routine (ISR)⏳ will generate a Software Interrupt when the operation is completed so the processor doesn't have to sacrifice its time and memory.

Summarizing for now: The processor is responsible for running the process and calculations, Kernel has the scheduler, IPC, ISR, and other device drivers, And a file system is responsible for managing the data Storage. This file system and kernel together are the Operating System. { ref below picture }.

System Calls and Process Scheduling: 🔄🎛️ ( FCFS, RR, SRT )

Now that we have a better understanding of the operating system, we can see that it requires information or a task in order to function. This task is a command that the user program sends to the operating system via a method call, which is also known as a system call.

  • FCFS — First Come First Serve
  • RR — Round Robin
  • SRT — Shortest Remaining Time

These Process scheduling algorithm is used by the kernel to choose the order in which the process will be executed. A brief explanation is included in the notes.

n! ( n factorial ) — n number of ways a process can be scheduled for one processor. The order will actually bechosen by the algorithm.

So to create a new process for the web browser, the user-level application (browser) needs to request the operating system’s assistance. This request is made through a system call, specifically the “fork” or “exec” system call. The “fork” system call creates a new process (child process) that is an exact copy of the calling process (parent process), while the “exec” system call replaces the current process with a new program (the web browser executable). tada..that's it😁

Conclusion

This is how an Operating system works backstage for the smooth processing of tasks and what looks like magic for the user is actually a bundle of system calls.

Ping me on LinkedIn for any further assistance Seeeeee yaa!!! 👋🏾

Bonus:

“The Linux was actually built on a combination replica of minix🦝 and Unix” where minix was a file system which is now optimized to be an Operating System.

Git repo : https://github.com/torvalds/linux 😉🤫Have Fun.

--

--

R.Devansh Shukla

I am an IoT / Embedded Full Stack Developer with over 2 years of experience researching and developing IoT, Embedded, and Software solutions from the ground up.