Site icon DataFlair

System Call in OS

OS System Call

FREE Online Courses: Enroll Now, Thank us Later!

We use system calls to provide an interface between a process and OS. A system call helps a program request services from the kernel. It is a programmatic method and the only entry point for the kernel system. These services are offered with the help of an API (Application Programming Interface).

Workings of a System Call in OS

Following are the steps on how a System Call works:
Step 1: The processor executes a process in the user mode until a system call interrupts it.
Step 2: Then on a priority basis, the system call is executed in the kernel mode.
Step 3: After the completion of system call execution, control returns to user mode.,
Step 4: The execution resumes in Kernel mode.

Need for System Calls

Following are the reasons we need system calls:

Services of System Call in Operating System

Following are the services provided by a system call:

Types of System calls in Operating System

The five types of System Calls are:

1. Process Control

It performs the tasks of process creation, process termination, etc.

Functions of process Control:

2. File Management

Technology is evolving rapidly!
Stay updated with DataFlair on WhatsApp!!

It handles jobs regarding file manipulation.

Functions of File Management:

3. Device Management

It helps in device manipulation like reading from device buffers, writing into device buffers, etc.

Functions of Device Management:

4. Information Maintenance

It handles information and information transfer between OS and the user program.

Functions of Information maintenance:

5. Communication

This is for interprocess communications.

Functions of interprocess communication:

Rules for passing Parameters for System Call

Following are the rules for passing parameters to the System Call:

Important System Calls Used in OS

Following are the important system calls used in an OS:

1. wait()

When a process is running, the rest of the processes stay in the waiting state and wait for their turn. This happens when a parent process creates a child process, and the parent process suspends until the child process is done executing. This suspension of the parent process occurs automatically with the help of the wait() system call. Control moves back to the parent process after the child process ends execution.

2. fork()

This system call allows a process to create copy processes of itself. A parent process creates a child process. This suspends the execution of the parent process until the child process executes.

3. exec()

This system call runs when an executable file replaces the older one when the process is still running. Though the original process identifier still remains as the old process is still executing, the new process replaces things like a stack, data, head, etc.

4. kill():

This system call sends a termination signal to a process and urges the process to exit. However, it doesn’t really kill a process but can have various meanings.

5. exit():

This system call terminates a process. program execution. It defines that the thread execution is complete and the OS can reclaim the resources used by the process.

Summary

System calls provide an interface between a process and an OS. Some important system calls used in OS are wait(), fork(), exec(), kill(), exit().

Categories Windows Unix
Process control CreateProcess(), ExitProcess(), WaitForSingleObject() fork(), exit(), wait()
Device manipulation SetConsoleMode(), ReadConsole(), WriteConsole() ioctl(), read(), write()
File manipulation CreateFile(), ReadFile(), WriteFile(), CloseHandle() open(), read(), write(), close() 
Information maintenance GetCurrentProcessID(), SetTimer(), Sleep() getpid(), alarm(), sleep()
Communication CreatePipe(), CreateFileMapping(), MapViewOfFile() pipe(), shm_open(), mmap()
Protection SetFileSecurity(), InitializeSecurityDescriptor(), SetSecurityDescriptor Group() chmod(), umask(), chown()
Exit mobile version