0% found this document useful (0 votes)
18 views7 pages

System Calls in OS

System calls are special functions that allow processes to request actions from the operating system that cannot be performed by normal functions, serving as an interface between the process and the OS. They operate in two modes: User Mode for process execution and Kernel Mode for executing system calls, which include types such as Process Control, File Management, Device Management, Information Maintenance, and Communication. Important system calls include wait(), fork(), exec(), kill(), and exit(), with specific rules for passing parameters during these calls.

Uploaded by

Swathi Tamma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

System Calls in OS

System calls are special functions that allow processes to request actions from the operating system that cannot be performed by normal functions, serving as an interface between the process and the OS. They operate in two modes: User Mode for process execution and Kernel Mode for executing system calls, which include types such as Process Control, File Management, Device Management, Information Maintenance, and Communication. Important system calls include wait(), fork(), exec(), kill(), and exit(), with specific rules for passing parameters during these calls.

Uploaded by

Swathi Tamma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

System Calls in OS (Operating System)

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?


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.
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.

1. User Mode: In this mode, execution is done on behalf of the user.


2. 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.
Types of System Calls in OS

There are mainly 5 types of system calls available:

 Process Control
 File Management
 Device Management
 Information Maintenance
 Communication

1. 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.
2. File Management: File manipulation events
like Creating, Deleting, Reading Writing etc are being classified under
file management system calls.
3. Device Management: Device Management system calls are being used
to request the device, release the device, and logically attach and detach
the device.
4. Information Maintenance: This type of system call is used to maintain
the information about the system like time and date.
5. 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.
Example of System Calls in Windows and Unix
Types of System Calls Windows

CreateProcess()

Process Control ExitProcess()

WaitForSingleObject()

CreateFile()

ReadFile()

File Management WriteFile()

CloseHandle()

SetConsoleMode()

Device Management ReadConsole()

WriteConsole()

GetCurrentProcessID()

Information Maintenance SetTimer()

Sleep()

CreatePipe()

Communication CreateFileMapping()

MapViewOfFile()
 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.

Rules for Passing Parameters in System Call

1. The floating-point parameters can’t be passed as a parameter in the


system call.
2. Only a limited number of arguments can be passed in the system call.
3. 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.
4. Parameters can be pushed and popped from the stack only by the
operating system.

Important System Calls Used in OS

1. 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.
2. 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.
3. 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.
4. 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.
5. 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.
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.

You might also like