@rkenmi - OS 101

OS 101

OS 101

Back to Top

Updated on January 21, 2024


A kernel is the core software application of the operating system. It is generally not intended to be interacted with from a user-level perspective.

Some responsibilities it can handle:

  • Hardware management
    • e.g. drivers, I/O
  • Optimizing resource utilization
  • Scheduling processes, managing locks, and resolving resource related conflicts
  • Memory management (e.g. virtual memory)
  • IPC
  • File system (e.g. virtual file system abstractions)

Examples: Windows kernel, Linux kernel


A hypervisor manages hardware resources such as CPU, memory, disk space as an abstraction across multiple operating systems or (virtual) instances. It acts as a multi-tenancy manager so that a single, bare metal computer can virtually host one or more operating system instances.

Example 1: When you are given your own Amazon EC2 instance, the instance is configured by the residing computer's hypervisor layer.

Example 2: Docker has a hypervisor layer to allocate CPU, memory, disk space into separate segments or containers.


A process is an OS level identity that has one or more threads allocated to it. On UNIX systems, a process is given a process ID and signals can be sent to processes to terminate or suspend it.

Example: ps aux | grep "spotify"


A fundamental primitive resource for executing some instruction. A thread generally refers to a CPU core's virtual thread. On commodity CPUs, each CPU core generally has two VCPU threads.

A single thread can be assigned to do some task. For example, Node.js is notorious for being known as a single-threaded server framework. This is due to Javascript inherently being single-threaded, and to perform tasks in an asynchronous fashion, it uses a single-threaded event loop.

Processes can use one or more threads, and applications can use one or more processes.

File Descriptors

A file descriptor is a number that uniquely identifies an open file in a computer's operating system. It describes a data resource, and how that resource may be accessed. For every open file, there exists a file descriptor, so if you have 100 files open, then you have 100 file descriptors.

When a program tries to open a file, the kernel will grant access to the program to open the file. It will then add an entry into the global file table corresponding to the file's descriptor ID. This allows other programs running in the OS to be able to look up this file, for reads/writes.

Reserved File Descriptors

Three file descriptors are reserved by the system, and may come across as very familiar to those who have worked a lot with I/O.

  • stdin (0)
  • stdout (1)
  • stderr (2)

File descriptors can be directly accessed in modern shells of Linux, allowing you to manipulate them by using techniques such as redirection.

For example, the following example will look for entries named foobar in the current directory and discard any errors thrown by this command by re-directing the stderr to /dev/null.

find . -name 'foobar' 2>/dev/null

Network Sockets

In UNIX, a socket is considered a special type of file.

class UnixFile:  

class Socket(UnixFile):  

Therefore, if we start a server process that takes up port 8000 on our local host, we can also anticipate one file descriptor for this port as well.

Article Tags:
operating system