How does a program ask the kernel for something?
A program cannot even open a file by itself. It has to ring a bell, and the kernel decides whether to answer.
▶ Start the storyA program asks the kernel for something through a system call. A system call is the way a program requests a service from the operating system it runs on, such as reading a file, using the camera, or starting another program.
Why can't a program just do these things itself? Because the processor and the operating system keep programs in a box. A program is usually limited to its own , so it cannot touch other programs or the operating system, and it is usually prevented from directly manipulating hardware. Yet applications do need hardware, so the operating system offers system calls as well-defined, safe ways to ask.
Here is the trip. The program triggers a signal, often an . The interrupt puts the processor into an elevated and hands control to the kernel, which looks at the request and determines whether the calling program should be granted the service. If it is, the kernel runs its own instructions, which the program cannot see or change, then lowers the privilege level and returns control to the program.
Step 1: Program asks
For example: open this file
Step 2:
The processor rises to a higher
Step 3: Kernel decides
Is this program allowed to have it?
Step 4: Kernel acts
Runs its own instructions
Step 5: Return
Privilege lowered, control back to the program
Think of a bank counter. You never walk into the vault; you ask the teller, who checks you may have what you asked for, fetches it and slides it across the glass.
In daily life you never notice any of this. Programs usually reach system calls through a that sits between them and the operating system, so a programmer just writes "open this file" and the library does the knocking.
Quiz me
0/3
Recap
A program never walks into the vault; it asks the teller, and the kernel decides.
💡 A trick to remember it · Teller behind the glass: you ask, the kernel checks your right, fetches the item, and slides it back.
Surprising fact · Linux has over 300 system calls and Windows close to 2000, while Plan 9 has only 54.
Connects to
- 🎟️ How does one processor seem to do many things at once?
- 🏃 What is a process, and how can one program run twice?
- 🧠 What is the kernel, the one program always in charge?
- 🌳 Why did a side project at Bell Labs shape so many modern operating systems?
- 🔓 Why did an NBA team hand over every employee's tax forms to a scammer?
Sources (2)
No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.