An operating system sits between your program and the hardware and shares the CPU, memory and devices among every running program. Your code never talks to the disk or network directly. It asks the OS through system calls, and the OS grants access.
The OS has three main jobs. It schedules CPU time, so many programs take turns on limited cores. It gives each program its own view of memory, so a bug in one program cannot overwrite another program's memory. It also manages files, devices and the network behind uniform interfaces.
This design lets your program act as if it has the machine to itself, while dozens of programs share it. Without the OS enforcing those boundaries, a single careless loop could freeze everything or read another program's secrets.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓