You are on page 1of 3

System Call in Operating System

A system call is the programmatic way in which a computer program requests a service from
the kernel of the operating system it is executed on. A system call is a way for programs to
interact with the operating system. A computer program makes a system call when it makes
a request to the operating system’s kernel. System call provides the services of the operating
system to the user programs via Application Program Interface (API). It provides an interface
between a process and operating system to allow user-level processes to request services of
the operating system. System calls are the only entry points into the kernel system. All
programs needing resources must use system calls.
The interface between a process and an operating system is provided by system calls. In
general, system calls are available as assembly language instructions. System calls are
usually made when a process in user mode requires access to a resource. Then it requests
the kernel to provide the resource via a system call.
A figure representing the execution of the system call is given as follows −

As can be seen from this diagram, the processes execute normally in the user mode until a
system call interrupts this. Then the system call is executed on a priority basis in the kernel
mode. After the execution of the system call, the control returns to the user mode and
execution of user processes can be resumed.

How System Calls Work

The Applications run in an area of memory known as user space. A system call connects to
the operating system's kernel, which executes in kernel space. When an application creates
a system call, it must first obtain permission from the kernel. It achieves this using an
interrupt request, which pauses the current process and transfers control to the kernel.
If the request is permitted, the kernel performs the requested action, like creating or deleting
a file. As input, the application receives the kernel's output. The application resumes the
procedure after the input is received. When the operation is finished, the kernel returns the
results to the application and then moves data from kernel space to user space in memory.

A simple system call may take few nanoseconds to provide the result, like retrieving the
system date and time. A more complicated system call, such as connecting to a network
device, may take a few seconds. Most operating systems launch a distinct kernel thread for
each system call to avoid bottlenecks. Modern operating systems are multi-threaded, which
means they can handle various system calls at the same time.
Why do you need system calls in Operating System?
• Process creation and management
• Main memory management
• File Access, Directory and File system management
• Device handling(I/O)
• Protection
• Networking, etc.
Types of System Calls
There are commonly five types of system calls. These are as follows:
• Process control: end, abort, create, terminate, allocate and free memory.
Process control is the system call that is used to direct the processes. Some process
control examples include creating, load, abort, end, execute, process, terminate the
process, etc.
• File management: create, open, close, delete, read file etc.
File management is a system call that is used to handle the files. Some file
management examples include creating files, delete files, open, close, read, write, etc.
• Device management
Device management is a system call that is used to deal with devices. Some examples
of device management include read, device, write, get device attributes, release
device, etc.
• Information maintenance
Information maintenance is a system call that is used to maintain information. There
are some examples of information maintenance, including getting system data, set
time or date, get time or date, set system data, etc.
• Communication
Communication is a system call that is used for communication. There are some
examples of communication, including create, delete communication connections,
send, receive messages, etc.
Examples of Windows and Unix System Calls
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()

You might also like