System calls in an operating system are the mechanisms through which programs interact with the kernel. It is through system calls that programs access the hardware, files, and memory, and many other resources. As a beginner, understanding their significance and how they differ from regular function calls can be confusing. In this article, we will discuss what is system call in operating system, how it works, its types, advantages and disadvantages, methods to pass parameters in OS, and the comparison between system calls and interrupts.
Table of Contents:
What is System Call in Operating System?
System call in OS is a mechanism to access the kernel, which operates in kernel mode. It provides the services of the operating system, like reading from a file, to user-space programs via an API without accessing system resources directly.
System calls provide an abstraction layer between the system components, like the CPU and memory, and user programs. They also act as a security mechanism, protecting the system from accidental errors and malicious attacks originating from other programs.
Fast-Track Your Software Engineering Career!
Enroll Now and gain hands-on experience and a prestigious certification to elevate your career!
Services Provided by System Calls in OS
A system call in operating system provides many services. Some of the common features are:
- Process creation and management
- Main memory management
- File Access, Directory, and File Handling
- Device handling (I/O)
- Protection
- Networking and many more
Features of System Calls in OS
The features of system calls in operating system include
- System calls in OS provide an interface between the user and the kernel of the operating system.
- They perform a context switch in the CPU from user mode to kernel mode and execute processes.
- When a service requested by the program fails, the system call returns an error code, which the program can use to display an appropriate error message..
- System calls in operating systems provide a protection mechanism for the privileged operations that protect the system from unauthorized access and attacks.
How do System Calls in Operating System work
You write a program, you give the command to run it, it gets executed, and the output is shown on the screen. The process appears to be fast and straightforward, but it is quite complex. A few more steps are going on in the background that most beginner programmers are not aware of. These steps are called system calls in operating system. It is the way a program or a process interacts with the kernel, which executes it. When the program is completely coded, the user initiates the execution of the process. When you run the compiled file using commands like ./myfile, the shell, which is a program itself, makes a system call to the kernel. Then, the kernel in the operating system executes the program and gives control to the parent process, often the shell, and the shell gives control back to the user. They make context switches from user mode to kernel mode.
Let’s explore how a program interacts with the kernel using system calls. We will take an example of a C program file named myfile.c. This program is to be run on a Linux system.

- When you run your C program using ./myfile in the terminal, the shell, a user-space program itself, doesn’t directly run your program. The shell makes a system call to the kernel using execve. It tells the kernel to load your myfile into memory and start executing it.
- Suppose your program needs to open a file. In C, you might write FILE *file = fopen(“example.txt”, “r”);. fopen() is not a system call in itself; it is a standard library function provided by C, which has functions with easy-to-remember names for the user.
- fopen() will make a system call to the kernel using the SYS_open command. This system call passes the filename and desired mode to the kernel. A context switch occurs; the CPU switches from user mode to kernel mode.
- Kernel mode has full access to the hardware. The kernel then verifies the request and performs the low-level operation of opening the file on your behalf.
- After the kernel successfully opens the file, it returns a file descriptor, which is an integer ID for the opened file, to your program. Another context switch occurs, and the CPU switches from kernel mode to user mode.
- Your program continues its execution from where it left off, now with the file successfully opened.
- When your program finishes execution, it makes another system call, exit_group, to inform the kernel that it has completely executed. The kernel then manages and cleans up the resources used in the program.
- Then, the kernel gives control back to the program’s parent process, in this case the shell, which presents the command prompt back to the user and is ready for the next command.

Get 100% Hike!
Master Most in Demand Skills Now!
Interrupts vs System Calls in Operating System
Learners and students who are new to the operating system concepts often confuse system calls and interrupts. On learning the primary function of both, they use them interchangeably, thinking the two are the same, but they are not. They might be similar, but they are different from each other based on many factors. Below is a table highlighting those differences.
Feature |
System Calls |
Interrupts |
Definition |
A mechanism by which a user program requests a service from the operating system. |
A signal sent to the processor indicating an event that needs immediate attention. |
Initiated By |
User program or application |
Hardware device or software |
Purpose |
To access OS services like file handling, memory management, etc. |
To handle asynchronous events like I/O completion, timers, errors, etc. |
Control Transfer |
Transfers control from user mode to kernel mode |
Also transfers control to the kernel, specifically the interrupt handler |
Execution Type |
Synchronous, which means it is triggered explicitly by a program |
Asynchronous, which means it can occur at any time |
Examples |
open(), read(), write(), fork() |
Keyboard input, mouse movement, timer interrupt, divide by zero |
Handled By |
Operating System kernel |
Interrupt Service Routine (ISR) or Interrupt Handler |
Priority |
Usually lower than interrupts |
Can have higher priority to handle time-sensitive events |
Types of System Calls in Operating System
All the system calls in OS can be divided into five broad categories. Let us explore all these categories briefly.
- Process Control: The process that creates the new process is called the parent process, and the newly created process is called the child process. The system calls in this category handle all the commands related to process management, like creating, exiting, and terminating a process, and many more.
- File management: These system calls in OS handle the operations related to a file, like creating, opening, loading, writing a file, and many more.
- Device management: The system calls for device management in OS are responsible for requesting and releasing a hardware device, repositioning the location from where read and write can happen, mounting and unmounting external devices to the system, and many more device-related system calls.
- Information maintenance: These system calls set and fetch the information for system, process, file, or device attributes. It manages the information in the systems and is responsible for changing it.
- Interprocess Communications: These system calls in OS allow processes to exchange information between them and therefore communicate. This is the process of establishing communication between processes is called inter-process communication, or IPC.

Some Common System Calls in Windows and Linux
These are some of the common system calls used in Windows and Linux in operating systems that you use more than you realize. This table covers a few of the system calls in OS.
Category |
Windows System Call |
Linux System Call |
Description |
Process Control |
CreateProcess() |
fork() |
Creates a new process. Windows creates a new process with a new address space, while Linux fork() duplicates the current process. |
|
ExitProcess() |
exit() |
Terminates the current process and returns an exit status. |
|
WaitForSingleObject() |
wait() |
Waits for a child process to terminate. |
File Manipulation |
CreateFile() |
creat() |
Creates a new file or opens an existing one for writing. |
|
ReadFile() |
read() |
Reads data from a file descriptor. |
|
WriteFile() |
write() |
Writes data to a file descriptor. |
|
CloseHandle() |
close() |
Closes an open file descriptor or handle. |
Device Manipulation |
SetConsoleMode() |
ioctl() |
Controls device parameters |
|
ReadConsole() |
read() |
Reads user input from the console (handled via file descriptor in Linux). |
|
WriteConsole() |
write() |
Writes output to the console. |
Information Maintenance |
GetCurrentProcessId() |
getpid() |
Returns the process ID of the current process. |
|
SetTimer() |
alarm() |
Sets a timer that sends a signal after a specified number of seconds. |
|
Sleep() |
sleep() |
Suspends process execution for a given number of seconds. |
Communication |
CreatePipe() |
pipe() |
Creates a one-way communication channel for inter-process communication (IPC) |
|
CreateFileMapping() |
shmget() |
Allocates a shared memory segment. |
|
MapViewOfFile() |
mmap() |
Maps files or devices into memory. |
Parameters of System Calls in Operating System
The functions of System calls in OS require specific parameters, like any other function in programming. It is these parameters that provide the kernel with all the necessary information required to execute the requested service. The parameters include details like
- The specific operation to be performed (like creating a file or reading data).
- The target on which the operation is to be performed (like the filename, the process ID).
- And finally, the values such as the memory address of a buffer to read into, the number of bytes to write, or specific flags or modes.
When a program in user space performs a system call, it first prepares the parameters of that particular system call. These parameters are usually placed in specific CPU registers or pushed onto the user-space program stack. Then, a system call instruction transfers control to the kernel, which accesses the locations for parameters of the system call to perform the requested task.
System performance depends on how efficiently these parameters are passed between the user and kernel spaces.
Methods to Pass Parameters to OS
User-space programs and the kernel both operate in different memory spaces due to security and isolation. When the kernel is in kernel mode, it can safely access known regions of memory belonging to the user process. A user program cannot directly write to kernel memory or execute privileged kernel operations.
For a system call to be effective, the kernel must get the necessary information from the user process, and the parameter-passing techniques are used. When the CPU switches into kernel mode for a system call, the kernel gains the ability to safely access and read a particular and verified part of the memory of the user process.
Therefore, parameters are passed using well-defined mechanisms that bridge this user-kernel boundary. Let us look at each of these mechanisms in detail with examples.
1. Passing Parameters in Registers
This method is the fastest way to pass parameters to the OS. In this method, the calling program, which is the program that has initiated the system call, places a few parameters (fewer than the number of registers) directly into the CPU registers when the system call is invoked.
Output:
Explanation: In the code above, the parameters fileName, accessMode, and permissions are passed to the open() system call. Internally, these arguments are placed into specific CPU registers before the kernel handles the request.
2. Passing Parameters in Stack
In this method, the calling program pushes the parameters onto the user-space stack. This way, the kernel can easily access the data by retrieving information from the top of the stack. When the system call occurs and the CPU switches to kernel mode, the kernel can then access and read these parameters directly from the user’s stack. While the kernel reads the parameters, the cleanup of the stack frame is handled by the user-space calling convention.
Output:
Explanation: Although abstracted in C, parameters to write() are pushed onto the stack before the system call is made, and the kernel reads them post mode-switch.
3. Passing Parameters to Block or Table in Memory
When the number of parameters is greater than the number of registers, this method is applied. The parameters are stored in blocks or tables, and then the memory address is saved in the registers as a parameter.
Dummy File: example.txt
Output:
Explanation: The stat() call passes a pointer to a memory block (structure) in a register. The actual data is in memory, not directly passed through registers or the stack.
Advantages of System Calls in Operating System
- Due to system calls, programs are able to access hardware devices like printers, disk drives, device drivers, network devices, and more.
- System calls in OS make inter-process communication possible. They allow programs to create and terminate processes.
- They help programs allocate and deallocate memory. Due to system calls in OS, they are able to access memory-mapped hardware devices.
- System calls in OS provide a way for programs to access fundamental operating system services, such as performing low-level input-output operations with files and devices, and keep them secure as well.
- They provide a consistent interface between the user programs and device operating systems. This makes them compatible across all hardware devices and operating system versions.
Disadvantages of System Calls in Operating System
- Each system call involves a transition from user mode to kernel mode, which adds latency. This adds performance overhead because the context switch from kernel mode to user mode slows down the execution of programs.
- Poorly implemented or misused system calls in operating system can expose the system to threats like unauthorized access, privilege escalation, or data leakage.
- Managing errors in system calls, such as memory allocation failures, requires low-level defensive programming. Debugging these issues can be complex, making error handling more challenging.
- Not all operating systems implement system calls in the same way. Developers developing for more than one OS, like Linux and Windows, may need to write separate code or use abstraction layers to maintain portability and compatibility.
Difference Between System Calls and API Calls
Beginners learning about system calls in operating system often confuse system calls and Application Program Interface calls. They are quite different from one another. Here is a table highlighting the primary differences.
Feature |
System Call |
API Call |
Definition |
The interface between the user program and OS kernel |
The interface between the user program and libraries |
Access Level |
Directly accesses OS kernel services |
Accesses services via function abstraction |
Mode of Execution |
Switches from user mode to kernel mode |
Executes in user mode |
Performance |
Slower due to context switching |
Faster, no mode switching |
Ease of Use |
Complex and low-level |
Simple and high-level |
Portability |
OS-specific |
More portable across platforms |
Example |
read(), write(), fork() |
fopen(), printf(), scanf() |
Upgrade Your Skills and Get Certified in C programming Language!
Enroll Now and accelerate your career with confidence!
Conclusion
In this article, we looked at the concept of system calls in operating systems in detail. We delved into the practical aspects of how they work from the program to the command prompt to the kernel. We also discussed a few of them in Windows and Linux and understood their functions. Understanding system calls in operating systems is fundamental to grasping how an operating system manages the whole computer system and the importance of program-kernel communication.
System Calls in OS (Operating System) – FAQs
Q1. What is system call in operating system?
A system call in operating system lets you request services from the operating system, like file handling or process control, through a controlled interface.
Q2. What are the five types of system calls?
You use system calls for process control, file manipulation, device manipulation, information maintenance, and communication between processes.
Q3. What is write system call in OS?
The write() system call sends data from your program to a file or output device, like the screen or a file descriptor.
Q4. Is printf() a system call in OS?
No, printf() is a C library function. It eventually uses system calls like write() to send output to the terminal.
Q5. Why are system calls important in modern operating systems?
System calls enable user programs to safely access OS services like file handling, memory, and I/O. They ensure security, resource control, and efficient hardware interaction, directly impacting app performance.