Operating Systems

What is an OS?

The program that multiplexes hardware and offers processes a usable machine.

Level: beginner

What is it?

The operating system is the trusted software layer between applications and hardware. It manages CPU time, memory, storage, devices, and isolation. Applications usually ask for services through libraries and system calls rather than controlling devices directly.

Why does it matter?

The OS makes a shared machine safer and easier to use. Multiple programs can run without each one having to implement disk drivers, memory protection, or CPU scheduling. Its abstractions also let applications survive differences between hardware models.

Mental model

Treat the OS as a resource manager and an abstraction layer. A process sees a private address space and files; underneath, the kernel maps those abstractions onto shared physical resources.

How it works

  • The kernel executes privileged operations and enforces protection boundaries; system libraries provide convenient higher-level APIs.
  • Scheduling shares CPU time among runnable threads. Memory management maps virtual addresses to physical pages and enforces access permissions.
  • Filesystems translate names such as /home/user/report.txt into metadata and blocks on storage.
  • Device drivers and kernel subsystems coordinate access to hardware; user-space services handle many policies outside the kernel.
  • Isolation limits the damage one process can do to another, but bugs in privileged code can cross that boundary.

Steps

  • A program starts; the loader maps its executable and libraries into a process address space.
  • The process calls a library API such as open(); the library may issue a system call to request kernel work.
  • The kernel validates arguments and permissions, coordinates with a filesystem or device, and returns a result or error.
  • The scheduler gives runnable threads CPU time; timer interrupts let the kernel regain control.

Real-world usage

  • Explaining how an application reaches a file or network socket.
  • Debugging permission errors, memory exhaustion, process stalls, and device failures.
  • Comparing operating-system designs and user-space versus kernel-space responsibilities.

Common mistakes

  • Saying the whole OS is the kernel; many services and utilities run in user space.
  • Treating a system call and a library function as identical; a library call may never enter the kernel.
  • Assuming every resource can be isolated perfectly; shared kernel and hardware vulnerabilities still matter.

Interview questions

What are the main responsibilities of an operating system?

Resource management (CPU, memory, storage, devices), abstractions for applications, and protection/isolation.

What is the difference between kernel space and user space?

Kernel space has privileged execution and access to protected machine state. User space is restricted and requests privileged work through controlled interfaces.

Trace a file read from an application to storage.

The application calls a library/API; a system call validates the request; the filesystem resolves the path and may request cached or device data; the result is copied or mapped back to the process. Actual I/O may be asynchronous or satisfied from cache.

Related concepts

Continue learning

Browse the full computer science library