0% found this document useful (0 votes)
16 views5 pages

System Call

Uploaded by

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

System Call

Uploaded by

Neel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Process control system calls


System call provides an interface between user program and operating system. The structure of
system call is as follows –

When the user wants to give an instruction to the OS then it will do it through system calls.
Or a user program can access the kernel which is a part of the OS through system calls.
It is a programmatic way in which a computer program requests a service from the kernel of
the operating system.

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

How Does the System Call Work?

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.

???for any type of access, do we have a specific type of system call?

Ans: Yes, we have different types of system calls.

Types of system calls:


The different system calls are as follows −
 System calls for Process management
 System calls for File management
 System calls for Directory management

Now let us discuss process management system calls.


System calls for Process management
Process management system calls in Linux.
 fork − For creating a duplicate process from the parent process.
 wait − Processes are supposed to wait for other processes to complete their work.
 exec − Loads the selected program into the memory.
 exit − Terminates the process.

The pictorial representation of process management system calls is as follows −

fork() − A parent process always uses a fork for creating a new child process. The child process
is generally called a copy of the parent. After execution of fork, both parent and child execute
the same program in separate processes.
exec() − This function is used to replace the program executed by a process. The child
sometimes may use exec after a fork for replacing the process memory space with a new
program executable making the child execute a different program than the parent.
exit() − This function is used to terminate the process.
wait() − The parent uses a wait function to suspend execution till a child terminates. Using wait
the parent can obtain the exit status of a terminated child.

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