Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 66 ยท Getting Started

What Is an Operating System?

Learn what an operating system does: it manages the CPU, memory, storage and devices, hides hardware details, and protects programs from each other. Includes a live demo.

An operating system (OS) is the program that runs all the other programs. When you power on a laptop or phone, the first large piece of software to take control is the OS. It sits between the hardware (CPU, memory, disks, network cards, screens) and the applications you actually care about (a browser, a game, a code editor). Windows, macOS, Linux, Android and iOS are all operating systems.

Why does such a layer exist? Without it, every application would have to know how to talk to every kind of disk, keyboard and network card, and two applications could overwrite each other's memory by accident. The OS solves both problems. It gives programs a simple, uniform view of the machine, and it makes sure many programs can share that one machine fairly and safely. In this lesson you will meet the two classic roles of an OS, its main jobs, and the vocabulary used in the rest of this course.

Where the OS sits

Applications Browser, editor, game.
Operating system Shares and protects the machine.
Hardware CPU, memory, disk, network.

Applications never touch the hardware directly; they ask the OS.

1 / 2

Two roles: extended machine and resource manager

Textbooks describe the OS in two complementary ways.

The OS as an extended machine (an abstraction layer). Raw hardware is ugly. To read a file from a disk you would need to send commands to a controller, wait for interrupts and handle bad sectors. The OS hides that behind friendly ideas: a file you can open, read and close; a process that seems to own the whole CPU; a socket that carries bytes across a network. These ideas are called abstractions. Good abstractions let a programmer write open("notes.txt") without knowing whether the file lives on an SSD, a USB stick or a network drive.

The OS as a resource manager. A computer has limited resources: CPU time, memory, disk space, network bandwidth. Many programs want them at once. The OS decides who gets what and when, and takes the resources back when a program ends. Its goals are to be efficient (keep expensive hardware busy), fair (no program is starved forever) and safe (one program cannot damage another).

The main functions

Area What the OS does Where in this course
Process management Creates, schedules and ends processes; lets them communicate Processes
Memory management Tracks which memory belongs to whom, uses disk as overflow Memory Management chapter
File system Names, stores and protects files and directories Files and Storage chapter
Device management Talks to hardware through drivers, buffers and queues I/O and Disk Scheduling chapter
Protection and security Enforces who may do what Protection and Security chapter
User interface Provides a shell (command line) or a graphical desktop below

Resource management in miniature

Real kernels are huge, but the core idea fits in a few lines. This toy "OS" owns 64 units of memory. Programs ask for blocks; the OS grants them if it can, refuses if it cannot, and reclaims the memory when a program exits.

Python A toy resource manager

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that the programs never touch total or allocations themselves. They only call methods. That is protection by interface, and it is how a real kernel works: applications make requests, and the kernel decides (system calls are the real mechanism).

What your own program can ask the OS

Every language runtime wraps OS services. The next example asks the environment a few questions. The answers differ per machine, which is the point: the OS is the thing that knows.

Python Asking the environment

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

On your laptop this would print win32, linux or darwin, the real core count, and \ or / as the separator. Here the code runs in a WebAssembly sandbox, so you see the browser-hosted environment instead. Even so, os.getpid() and os.sep show how the OS exposes process identity and file-name conventions.

Goals and design trade-offs

Operating systems are built for different goals, and they pull in different directions:

  • Convenience vs. efficiency. A desktop favors responsiveness; a supercomputer favors raw throughput.
  • Generality vs. specialization. A phone OS is tuned for battery life and touch; a router OS is tuned for forwarding packets.
  • Protection vs. speed. Checking every request costs time, but skipping checks invites bugs and attacks.

You will see these trade-offs again in scheduling, memory management and file systems.

User interface: shell and GUI

The part of the OS you see is the user interface. A command-line interface (CLI or shell) reads typed commands such as ls or dir. A graphical user interface (GUI) shows windows and icons. Both are ordinary programs that call the OS on your behalf; neither is "the OS" itself. That is why you can swap shells on Linux, or run a server with no GUI at all. The Linux tutorial teaches the shell in depth.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which description best fits the OS as a resource manager?

    A resource manager allocates scarce resources (CPU time, memory, disk, devices) among competing programs and reclaims them afterward.
  2. 2. Why do applications call the OS instead of touching hardware directly?

    The OS provides abstractions (files, processes) and enforces protection, which is only possible if programs go through it.
  3. 3. Which of these is NOT normally a function of an operating system?

    Compilers are ordinary application programs. The OS runs them like any other program but does not itself translate source code.
  4. 4. A shell or desktop is best described as

    Shells and GUIs are programs that sit on top of the kernel and make system calls for you.

Summary

  • An OS manages hardware resources and gives programs easy abstractions over them.
  • Two views: extended machine (hide ugly hardware) and resource manager (share it fairly and safely).
  • Main jobs: process, memory, file and device management, plus protection and a user interface.
  • Programs request services from the OS rather than using hardware directly.
  • Design always balances convenience, efficiency, generality and safety.

Next: Types of Operating Systems