System Call in OS (Operating System) - What Is, Types and Examples
System Call in OS (Operating System) - What Is, Types and Examples
https://www.guru99.com/system-call-operating-system.html 1/8
7/19/22, 11:58 AM System Call in OS (Operating System): What is, Types and Examples
EXPLORE MORE
Learn Java
Programming with
Beginners Tutorial
08:32
What is Integration
Testing Software
For example if we need to write a program code to read data from one file, copy that data
into another file. The first information that the program requires is the name of the two files,
the input and output files.
In an interactive system, this type of program execution requires some system calls by OS.
First call is to write a prompting message on the screen
Second, to read from the keyboard, the characters which define the two files.
How System Call Works?
Here are the steps for System Call in OS:
Step 1) The processes executed in the user mode till the time a system call interrupts it.
Step 2) After that, the system call is executed in the kernel-mode on a priority basis.
Step 3) Once system call execution is over, control returns to the user mode.,
Step 4) The execution of user processes resumed in Kernel mode.
Why do you need System Calls in OS?
Following are situations which need system calls in OS:
Reading and writing from files demand system calls.
If a file system wants to create or delete files, system calls are required.
System calls are used for the creation and management of new processes.
Network connections need system calls for sending and receiving packets.
Access to hardware devices like scanner, printer, need a system call.
https://www.guru99.com/system-call-operating-system.html 4/8
7/19/22, 11:58 AM System Call in OS (Operating System): What is, Types and Examples
https://www.guru99.com/system-call-operating-system.html 6/8
7/19/22, 11:58 AM System Call in OS (Operating System): What is, Types and Examples
This system call runs when an executable file in the context of an already running process
that replaces the older executable file. However, the original process identifier remains as
a new process is not built, but stack, data, head, data, etc. are replaced by the new
process.
kill():
The kill() system call is used by OS to send a termination signal to a process that urges the
process to exit. However, a kill system call does not necessarily mean killing the process
and can have various meanings.
exit():
The exit() system call is used to terminate program execution. Specially in the multi-
threaded environment, this call defines that the thread execution is complete. The OS
reclaims resources that were used by the process after the use of exit() system call.
Summary:
Categories Windows Unix
CreateProcess() fork()
Process control ExitProcess() exit()
WaitForSingleObject() wait()
SetConsoleMode() loctl()
Device manipulation ReadConsole() read()
WriteConsole() write()
CreateFile() Open()
ReadFile() Read()
File manipulation
WriteFile() write()
CloseHandle() close!)
GetCurrentProcessID() getpid()
Information maintanence SetTimer() alarm()
Sleep() sleep()
CreatePipe() Pipe()
Communication CreateFileMapping() shm_open()
MapViewOfFile() mmap()
SetFileSecurity() Chmod()
Protection InitlializeSecurityDescriptor() Umask()
SetSecurityDescriptorGroup () Chown()
https://www.guru99.com/system-call-operating-system.html 7/8
7/19/22, 11:58 AM System Call in OS (Operating System): What is, Types and Examples
https://www.guru99.com/system-call-operating-system.html 8/8