Beginner Topic 4 of 51 Operating Systems
System Calls
Controlled entry points for programs to request kernel services.
How it works
A system call is the controlled interface through which a user program requests a service from the kernel, such as reading a file, creating a process, allocating memory or sending network data. The program places arguments in registers, executes a special instruction like syscall or int 0x80, the CPU switches to kernel mode and runs the handler, and the result returns to user space. Libraries like libc wrap raw calls in friendly functions.
Step-by-step walkthrough
- The program calls read(fd, buf, n).
- The library puts the call number in a register and traps.
- The kernel validates the arguments and does the work.
- It copies the data and returns a result or an error code.
- The library returns to the program.
Where it is used
Opening and reading files, fork and exec, mmap, socket, write and exit are system calls. Tools such as strace show them, which helps debug what a program really does.
Common pitfall
Each call has overhead from the mode switch and argument checking, so batch operations and use buffering. Failing to check return values and error codes such as errno causes silent bugs. Partial reads and writes, and calls interrupted by signals, need handling in loops.
Where it fits in the course
System Calls is topic 4 of 51 in Operating Systems, rated Beginner. It follows User Mode vs Kernel Mode. The next topic is Processes.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Operating Systems quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Operating Systems quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is System Calls?
Where do people use System Calls?
What is the most common mistake with System Calls?
What should I learn before this topic?
How can I practice it?
Is System Calls hard to learn?
How long does it take to learn System Calls?
Which topics are related to System Calls?
What should I study after System Calls?
Related topics
- User Mode vs Kernel Mode (Operating Systems)
- Processes (Operating Systems)
- Kernel (Operating Systems)
- Process States (Operating Systems)
- Binary Number System (Computer Architecture & Logic)
- What is a Distributed System (Distributed Systems & Cloud)
- Linux File System Layout (DevOps & Tooling)