Last Updated:

System Calls in Operating Systems: Examples and Types

Introduction

Operating systems (OS) form the backbone of modern computing, providing the interface between software applications and hardware resources. One of the essential components of an operating system is its ability to manage system-level operations, which it does through system calls. These are the mechanisms by which a program requests services from the OS's kernel.


What are System Calls?

A system call is a programmatic way in which a program requests a specific service from the operating system’s kernel. System calls provide an interface between the user-space (where applications run) and the kernel-space (which has direct access to hardware resources). They allow a program to perform tasks such as file manipulation, process management, and hardware communication, which it cannot do by itself due to security and resource protection constraints.


How Do System Calls Work?

System calls are invoked through an API (Application Programming Interface) that abstracts the complexity of interacting directly with the kernel. A program triggers a system call by placing a special value in a register (or a set of registers) and then executing a trap instruction. This causes a context switch, where the CPU switches from user mode to kernel mode to execute the required system-level operation.

Once the OS kernel has completed the requested operation, control is returned to the user program, and it resumes its execution in user mode.


Types of System Calls


Examples of System Calls in Popular Operating Systems

Operating System Example System Calls
Unix/Linux open(), fork(), exec(), exit()
Windows CreateProcess(), ReadFile(), WriteFile()
MacOS fork(), exec(), open()

Conclusion

System calls are essential for the functionality of modern operating systems, providing a controlled interface for user programs to interact with the system's hardware and services. By understanding the types of system calls and their roles, developers can write more efficient programs and leverage OS capabilities more effectively.