System Calls in OS (Operating System)
Overview
System call is the special function that is used by the process to request action from the operating system which cannot be carried out by normal function. System calls provide the interface between the process and the operating system.
What are System Calls in OS?
A system call is the controlled way a program asks the operating system to do something it is not allowed to do itself, like read a file, start a process, or send data over a network. It switches the CPU from user mode to kernel mode through a trap, runs the kernel's code, and returns the result.
Professor: Now that we know what a system call does, let’s understand how a process interacts with the operating system through it. But first, Alice, can you tell me the two main functions of the operating system (OS)?
Alice: Resource allocation and Providing environment so that process can execute
Professor: Very good Alice, seems like you have your basics clear. So now let’s understand how the process interacts with the OS. What are system calls in OS, Different Types of System calls, and a few examples of system calls as well?
When the process is being run, if the process requires certain actions that need to be carried out by Operating System, the process has to go call the function which can interact with the kernel to complete the actions. This special type of function call is known as System Calls in OS. System calls provide the interface so that the process can communicate with the Operating System.
Note: Kernel is the core component of the Operating System that has complete control of the hardware.
Note: Kernel is the core component of the Operating System that has complete control of the hardware.

Bob: But Professor, How are System Calls in OS made?
Professor: Let’s understand that in detail bob.
Build an AI-First Career, Master the Complete Skillset
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
AI Forward Deployed Engineer Program
Full-stack engineering, production AI and client-facing consulting
+1000 moreSystem Call vs Library Function
When a program needs a service from the operating system, it can use a library function that eventually makes a system call. A library function runs in user mode, while a system call transfers control to the kernel so the operating system can perform the requested operation.
For example, printf() is a C library function, not a system call. It formats and prepares the output in user space and can use the write() system call to send that output to the kernel.
The difference can be understood as follows:
| Library Function | System Call |
|---|---|
| Runs in user mode | Runs in kernel mode after the system call transition |
| Part of a programming library | Provides an interface to the operating system |
| Can perform its work without entering the kernel | Enters the kernel when OS-level access is required |
| Example: printf() | Example: write() |
Want to experiment with these C functions yourself? You can use an online C compiler to compile and run simple programs and see how library functions and system calls work in practice.
Professor: So, Bob, if you use printf() to display something on the screen, is printf() itself a system call?
Bob: No Professor. printf() is a library function that can use the write() system call to request the operating system to write the output.
Professor: Exactly. That is the difference between a library function and a system call.
How Does the System Call Work?
Professor: Before an understanding of the working of system calls in OS let us understand the important concept of modes of operation.
In our computer system, we have two modes available.
- User Mode: In this mode, execution is done on behalf of the user.
- Monitor/Kernel-Mode: In this mode, execution is done on behalf of OS.

- So when the process is under execution process executes under user mode, but when the process requires some OS resources to complete the task, the process makes a system call.
- System calls in OS are executed in kernel mode on a priority basis.
- On completion of the system call, the control is passed to process in user mode.
- The process continues the execution in user mode.
Alice: Professor, for any type of access, do we have a specific type of system call?
Professor: Yes Alice, we have different types of system calls, which we will see in the next section.
Types of System Calls in OS
There are mainly 5 types of system calls available:
- Process Control
- File Management
- Device Management
- Information Maintenance
- Communication

- Process Control: It handles the system calls for process creation, deletion, etc. Examples of process control system calls are: Load, Execute, Abort, and Wait for Signal events for process.
- File Management: File manipulation events like Creating, Deleting, Reading Writing etc are being classified under file management system calls.
- Device Management: Device Management system calls are being used to request the device, release the device, and logically attach and detach the device.
- Information Maintenance: This type of system call is used to maintain the information about the system like time and date.
- Communications: In order to have interprocess communications like send or receive the message, create or delete the communication connections, to transfer status information etc. communication system calls are used.
Professor: I know this is a bit theoretical, so let’s see some real-world system calls.
System calls can be grouped into five main categories based on the type of operation they perform. The table below summarises these categories along with examples from Unix and Windows.
| No. | Type of system call | What it does | Unix example | Windows example |
|---|---|---|---|---|
| 1 | Process Control | Create, run, wait for and end processes | fork(), exec(), exit(), wait() | CreateProcess(), ExitProcess() |
| 2 | File Management | Create, open, read, write, close and delete files as part of how the OS manages files on disk. | open(), read(), write(), close() | CreateFile(), ReadFile() |
| 3 | Device Management | Request, release and control devices | ioctl(), read(), write() | SetConsoleMode(), ReadConsole() |
| 4 | Information Maintenance | Get and set system time, date and process attributes | getpid(), alarm(), sleep() | GetCurrentProcessID(), SetTimer() |
| 5 | Communication | Pass messages and share memory between processes, with memory management in an operating system and process synchronisation relevant to how these processes work together. | pipe(), shmget(), mmap() | CreatePipe(), MapViewOfFile() |
Example of System Calls in Windows and Unix
| Types of System Calls | Windows | Linux |
|---|---|---|
| CreateProcess() | fork() | |
| Process Control | ExitProcess() | exit() |
| WaitForSingleObject() | wait() | |
| CreateFile() | open() | |
| ReadFile() | read() | |
| File Management | WriteFile() | write() |
| CloseHandle() | close() | |
| SetConsoleMode() | ioctl() | |
| Device Management | ReadConsole() | read() |
| WriteConsole() | write() | |
| GetCurrentProcessID() | getpid() | |
| Information Maintenance | SetTimer() | alarm() |
| Sleep() | sleep() | |
| CreatePipe() | pipe() | |
| Communication | CreateFileMapping() | shmget() |
| MapViewOfFile() | mmap() |
Professor: As we can’t see each and every system call in detail, let us take read() system call of file management and understand how it works.

- As we can see in the diagram, initially, the process pushes the parameter onto the stack.
- After that, the read routine from the library is called, which puts the system call code (unique code for each system call is assigned) into the register.
- Trap instruction is used which causes the transfer of control from user mode to kernel mode.
- Kernel reads the system call code present in the register and finds out that the system call is read, so the system call handler executes the read system call.
- After the execution of the read system call, the transfer is given back to the user mode.
- The library routine (Library routine is nothing but the line of codes that forms the library and the functions that can be called by the process so that we don't need to write the function every time. e.g... max function) in user mode returns the output to the process which called it.
- On receiving the output, the process continues to execute the next instruction.
Note: Trap is the kind of interrupt that is synchronous to the process for executing the functionality.
Bob: ohh! Never thought that simply reading our computer carries out so many tasks.
Professor: Yes Bob, but do you know what parameters we can pass to the system call?
Bob: No professor, and let me guess! Is this the next topic that we will be studying?
Professor: Smart Bob!
Bob: Giggle
Rules for Passing Parameters in System Call
- The floating-point parameters can’t be passed as a parameter in the system call.
- Only a limited number of arguments can be passed in the system call.
- If there are more arguments, then they should be stored in the block of memory and the address of that memory block is stored in the register.
- Parameters can be pushed and popped from the stack only by the operating system.
Professor: Let’s see some important system calls of our computer system.
How Scaler Transformed Careers in Different Fields
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Important System Calls Used in OS
- wait(): There are scenarios where the current process needs to wait for another process to complete the task. So to wait in this scenario, wait() system call is used.
- fork(): This system call creates the copy of the process that has called it. The one which has called fork is called the parent process and the newly created copy is called the child process.
- exec(): This system call is called when the running process wants to execute another executable file. The process id remains the same while the other resources used by the process are replaced by the newly created process.
- kill(): Sometimes while working, we require to terminate a certain process. So kill system call is called which sends the termination signal to the process.
- exit(): When we are actually required to terminate the program, an exit system call is used. The resources that are occupied by the process are released after invoking the exit system call.
Alice: Professor, so kill() system call won’t necessarily terminate the process, right?
Professor: Correct Alice, good you understood that. Most students get confused with that system call. Let’s recall what we learned.
Take your first step towards mastering operating systems. Enroll in our Operating System free course and develop a comprehensive understanding of OS.
Conclusion
- System call is the interface through which the process communicates with the system call.
- Computer system operates in two modes: User Mode and Kernel Mode
- Process executes in user mode, and when a system call is made, the mode is switched to kernel mode. Once the system call execution is completed, the control is passed back to the process in user mode.
- System calls in OS are made by sending a trap signal to the kernel, which reads the system call code from the register and executes the system call.
- Major type of sytem calls are Process Control, File Management, Device Management, Information maintenance and Communicaiton.
- Rules for parameter passing while making a system call are it should not be a floating number, a limited number of arguments should be passed and if arguments are more, they should be stored in a memory block and the address of that memory block should be passed, and the push, pop operations from the stack will be made only by the operating system.
- wait(), fork(), exec(), kill() and exit() are few important system calls of our computer system.
FAQs
Turn Learning into Career Growth
1. What is a system call in an operating system?
A system call is the controlled way a program requests a service from the operating system that it cannot perform directly. It allows the program to access resources such as files, processes, or devices by switching from user mode to kernel mode and returning the requested result.
2. Is printf a system call?
No. printf() is a C library function, not a system call. It formats the text and buffers it in user space before using the write() system call to pass the bytes to the kernel. When you trace the program with strace, you see the write() call rather than printf().
3. What are the five types of system calls?
The five main types of system calls are process control, file management, device management, information maintenance, and communication. These categories group system calls according to the type of operating system service they provide. The table in this section lists the main functions and examples for each category.
4. What is the difference between a system call and a library function?
A library function runs in user mode as part of your program. A system call crosses into kernel mode through a trap so the operating system can perform a service that the program cannot perform directly. Library functions can provide a simpler interface and may use system calls when kernel services are required.
5. How does a system call switch to kernel mode?
A system call switches to kernel mode through a trap, which is a synchronous software interrupt. The system call number identifies the requested service, and the CPU switches to kernel mode. The corresponding handler is found through the system call table, executed, and control then returns to user mode.
6. Why does Windows have no fork()?
Windows creates a process and loads its program through CreateProcess(). Unix handles these steps separately: fork() creates a new process, while exec() replaces its process image with a new program. Therefore, CreateProcess() and the Unix fork()/exec() combination are equivalents for process creation, rather than exact one-to-one matches.