Lesson 1 · Operating Systems

Introduction to Operating Systems

An operating system runs between applications and computer hardware. It starts programs, assigns resources, protects data, stores files, and gives applications a consistent way to use different devices.

Introduction to Operating Systems concept diagramA visual explanation of the layout and operations shown in this lesson.ApplicationOSCPUMemoryDevicesHardwarerequestapplications use hardware through services managed by the operating system
1

Where the operating system sits

A computer contains hardware, an operating system, system tools, and applications. Applications such as browsers and editors do not normally program the disk controller or network card directly. They ask the operating system to perform those operations.

The operating system hides hardware differences behind common services. A file can be opened through the same programming interface whether its bytes eventually come from an SSD, a removable drive, or a network file system.

  • Applications run in user mode
  • The kernel runs with permission to control hardware
  • Device drivers translate general requests into device-specific commands
2

Resources managed by the OS

CPU time is divided among runnable programs. Memory pages are assigned and protected. File systems name persistent data. Input and output requests are queued and completed by drivers.

The operating system must track who owns each resource and what operations are allowed. This bookkeeping is what lets many applications appear to run at the same time without freely damaging one another.

  • Processor scheduling
  • Memory allocation and protection
  • Files and directories
  • Devices and networking
Key reference

Terms, operations, and practical uses

System layers

  • ApplicationA user program that requests services instead of controlling hardware directly.
  • KernelThe privileged core that manages processors, memory, files, and devices.
  • DriverKernel-side software that translates a general request into commands for one device.

Managed resources

  • CPU timeScheduled among runnable threads.
  • MemoryAllocated, translated, protected, and reclaimed.
  • Persistent storageNamed through files and directories rather than raw device sectors.
  • Input and outputQueued and completed through drivers and interrupts.

Why the OS exists

  • ConvenienceApplications use consistent services across different hardware.
  • IsolationOne process cannot freely read or overwrite another process's memory.
  • CoordinationShared resources are assigned without requiring every application to negotiate directly.
Code example

Read and display a file through operating-system services

from pathlib import Path

# write() and read() are both system calls into the kernel
Path("notes.txt").write_text("hello")

text = Path("notes.txt").read_text()
print(text)
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

int main() {
    ifstream file("notes.txt");
    string text;
    getline(file, text);
    cout << text << '\n';
}
import java.nio.file.Files;
import java.nio.file.Path;

class Main {
    public static void main(String[] args) throws Exception {
        String text = Files.readString(Path.of("notes.txt"));
        System.out.println(text);
    }
}
Inputnotes.txt contains: hello
Outputhello
Example

Run the example step by step

Output
3

Convenience and protection

Without an operating system, every application would need code for every device and would have unrestricted access to memory. The OS provides reusable services while enforcing boundaries between applications.

Protection is based on hardware support as well as software rules. CPU privilege levels and memory translation allow the kernel to stop ordinary application instructions from accessing protected regions.

  • A consistent programming interface
  • Isolation between processes
  • User accounts and access permissions
  • Recovery and error reporting
4

From power-on to a running application

Firmware performs initial hardware setup and loads a boot program. The boot program places the kernel in memory. The kernel initializes drivers, memory management, scheduling, and the first user-space services.

When a user launches an application, the OS creates a process, maps its program and libraries into memory, prepares a thread, and places that thread in the scheduler's ready queue.

  • Firmware starts the boot chain
  • Kernel initializes core services
  • System services prepare the user environment
  • The scheduler runs application threads