Overview of Operating System

How an OS works in general?

Matthew Wong
3 min readAug 7, 2020

What’s an Operating System(OS)?

An Operating System(OS) is simply a bundle of software and it helps us to deal with complicated and tedious things like Scheduling(how each CPU handles your applications), File System(where your files are located inside your HD), and more other perplexing stuffs.

It’s just like a Tiger Mum:) and she helps you to handle things like preparing your timetable and organising your textbooks so that you can focus on doing your homework.

Full picture of what‘s inside an OS

What’s inside an OS? In general, an OS includes a main program called “Kernel”. It helps us to manage all the physical hardware of the computer, including CPU, RAM, hard disk, etc. It provides some functions as system calls for others programs to configure the kernel or build things on top (e.g. C library).

Apart from the Kernel, it consists of other programs. “Drivers” handles the interaction between the kernel and the external devices(e.g., keyboard) and a “Shell” gives you a simple command-line user interface with a full set of
commands to access OS’s services. Normally, a shell won’t manipulate the kernel directly and it needs the help from system calls. We’ll talk about it later.

Now, having the brief idea of what an OS is and what it has, we’re gonna discuss some essential concepts one by one to understand the OS world.

What’s a process?

A process is an execution instance of a program.

A process is more than just a program. It has states concerning about the execution. For example, the current line of code it’s executing and the estimated time remaining before returning CPU to other processes.

What’s a shell?

A shell is program which gives us a user interface or command-line interface to access OS’s services. When we open a Terminal, we actually launch a “shell” process. By the way, we’re using bash in Linux.

We can see that the first executing process when we opened the Mac Terminal is bash

What’s a system call?

A system call is just a function call. It’s exposed by the kernel and it helps us to abstract away most low-level details.

Example of a system call:

int main(void) {

// invoke time(time_t * t) function
// access the hardware clock
time(NULL);
return 0;}

How do we know if a function is really a system call? We can read the man page “syscalls” under Linux:

In general, system calls can be categorised as follow:

  1. Process
  2. File System
  3. Memory
  4. Security
  5. Device

Sometimes, system call is too primitive and is not programmer-friendly. That’s why we have Library calls to avoid some complex calls.

Take fopen() as an example:

// library call and it invokes the system call open()
fopen(“hello.txt”, “w”);
// system call
open(“hello.txt”, O_WRONLY | O_CREAT | O_TRUNC, 0666);

So far, I believe you know the basic concept of an Operating System and some vital terms like kernel, shell, system call, process, etc. We’re gonna go deeper into the sophisticated OS world:

Process management

Interprocess communication

  • Memory management
  • Threads and concurrency
  • Scheduling
  • I/O management
  • Networking

To know more about my backend learning path, check out my journey here:

--

--