The Wayback Machine - https://web.archive.org/web/20240909210305/https://www.geeksforgeeks.org/linux-system-call-in-detail/
Open In App

Linux system call in Detail

Last Updated : 08 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

A system call is a procedure that provides the interface between a process and the operating system. It is the way by which a computer program requests a service from the kernel of the operating system.

Different operating systems execute different system calls.

In Linux, making a system call involves transferring control from unprivileged user mode to privileged kernel mode; the details of this transfer vary from architecture to architecture. The libraries take care of collecting the system-call arguments and, if necessary, arranging those arguments in the special form necessary to make the system call.

System calls are divided into 5 categories mainly :

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

Process Control :

This system calls perform the task of process creation, process termination, etc.

The Linux System calls under this are fork() , exit() , exec().

  • fork()
    • A new process is created by the fork() system call.
    • A new process may be created with fork() without a new program being run-the new sub-process simply continues to execute exactly the same program that the first (parent) process was running.
    • It is one of the most widely used system calls under process management.
  • exit()
    • The exit() system call is used by a program to terminate its execution.
    • The operating system reclaims resources that were used by the process after the exit() system call.
  • exec()
    • A new program will start executing after a call to exec()
    • Running a new program does not require that a new process be created first: any process may call exec() at any time. The currently running program is immediately terminated, and the new program starts executing in the context of the existing process.

File Management :

File management system calls handle file manipulation jobs like creating a file, reading, and writing, etc. The Linux System calls under this are open(), read(), write(), close().

  • open():
    • It is the system call to open a file.
    • This system call just opens the file, to perform operations such as read and write, we need to execute different system call to perform the operations.
  • read():
    • This system call opens the file in reading mode
    • We can not edit the files with this system call.
    • Multiple processes can execute the read() system call on the same file simultaneously.
  • write():
    • This system call opens the file in writing mode
    • We can edit the files with this system call.
    • Multiple processes can not execute the write() system call on the same file simultaneously.
  • close():
    • This system call closes the opened file.

Device Management :

Device management does the job of device manipulation like reading from device buffers, writing into device buffers, etc. The Linux System calls under this is ioctl().

  • ioctl():
    • ioctl() is referred to as Input and Output Control.
    • ioctl is a system call for device-specific input/output operations and other operations which cannot be expressed by regular system calls.

Information Maintenance:

It handles information and its transfer between the OS and the user program. In addition, OS keeps the information about all its processes and system calls are used to access this information. The System calls under this are getpid(), alarm(), sleep().

  • getpid():
    • getpid stands for Get the Process ID.
    • The getpid() function shall return the process ID of the calling process.
    • The getpid() function shall always be successful and no return value is reserved to indicate an error.
  • alarm():
    • This system call sets an alarm clock for the delivery of a signal that when it has to be reached.
    • It arranges for a signal to be delivered to the calling process.
  • sleep():
    • This System call suspends the execution of the currently running process for some interval of time
    • Meanwhile, during this interval, another process is given chance to execute

Communication :

These types of system calls are specially used for inter-process communications.

Two models are used for inter-process communication

  1. Message Passing(processes exchange messages with one another)
  2. Shared memory(processes share memory region to communicate)

The system calls under this are pipe() , shmget() ,mmap().

  • pipe():
    • The pipe() system call is used to communicate between different Linux processes.
    • It is mainly used for inter-process communication.
    • The pipe() system function is used to open file descriptors.
  • shmget():
    • shmget stands for shared memory segment.
    • It is mainly used for Shared memory communication.
    • This system call is used to access the shared memory and access the messages in order to communicate with the process.
  • mmap():
    • This function call is used to map or unmap files or devices into memory.
    • The mmap() system call is responsible for mapping the content of the file to the virtual memory space of the process.
       

These are the various system calls involved in LINUX operating system.



Similar Reads

Difference Between System Call and library call
For anyone dealing with computer programming especially when it comes to performance issues or dealing with operations systems, it is very important to know the difference between system calls and library calls. System calls can be said as a way through which programs can ask the Kernel of an operating system for a certain service on the other hand
7 min read
Xv6 Operating System -adding a new system call
Prerequisite - Xv6 Operating System -add a user program In last post we got to know how to add user program in Xv6 Operating System. Now here you will see how to add new system call in Xv6 Operating System. A dding new system call to xv6: A system call is way for programs to interact with operating system. A computer program makes system call when
6 min read
Fork System Call in Operating System
In many operating systems, the fork system call is an essential operation. The fork system call allows the creation of a new process. When a process calls the fork(), it duplicates itself, resulting in two processes running at the same time. The new process that is created is called a child process. It is a copy of the parent process. The fork syst
5 min read
TheSpeedX / TBomb - Call and SMS Bomber for Kali Linux
TBomb is a free and open-source tool available on GitHub which is used to perform call and SMS bombing on the target phone number. This is the best tool for performing pranks on someone. This tool is written in python, so you must have python installed in your kali linux operating system. This tool works with open-source intelligence APIs that's wh
2 min read
Exodus - Copy Linux Binaries From One Linux System
Exodus is an easy-to-implement program, that is used for bundling dependencies, and also helps to effectively copy Linux ELF binaries from one to another machine securely, and this is very handy when you don't have root access, also if there are issues in the availability of the packages in the Linux distribution, Commonly Server oriented distribut
3 min read
Implementation of sleep (system call) in OS
In this article, we are going to learn about sleep (system call) in operating systems. In the computer science field, a system call is a mechanism that provides the interface between a process and the operating system. In simple terms, it is basically a method in which a computer program requests a service from the kernel of the operating system. W
4 min read
Difference between system() and execl() call
A system() call is a way for the programs to interact with the operating system. It is used to execute a command within a process. The 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 an operating system and it does not replace the
4 min read
What is System Call Interposition?
SystÐĩm calls IntÐĩrposition is a valuablÐĩ approach that allows intÐĩrcÐĩption and modification of systÐĩm calls madÐĩ in thÐĩ opÐĩrating systÐĩm. This tÐĩchniquÐĩ makÐĩs it ÐĩasiÐĩr to ÐĩnforcÐĩ finÐĩ-grainÐĩd sÐĩcurity policiÐĩs and intÐĩgratÐĩ nÐĩw capabilitiÐĩs, rÐĩsulting in a morÐĩ flÐĩxiblÐĩ and adaptablÐĩ sÐĩcurity modÐĩl. While it may not be thÐĩ ultimatÐĩ solution for sy
4 min read
Code for Fork System Call in OS
Fork is a system call in the Operating System used to create a copy of the process, the copied process created is known as the child process. The main process or the process from which the child process is created is known as the parent process. The parent and child processes are in separate address spaces in fork(). A Child process will have its P
4 min read
Introduction of System Call
A system call is a 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 requests the operating system's kernel. System call provides the services of the opera
11 min read
Remote Procedure Call (RPC) in Operating System
Remote Procedure Call (RPC) is a powerful technique for constructing distributed, client-server based applications. It is based on extending the conventional local procedure calling so that the called procedure need not exist in the same address space as the calling procedure. The two processes may be on the same system, or they may be on different
8 min read
Difference Between Arch Linux and Kali Linux
Arch Linux is an open-source Linux-based Operating System that is freely available for use. It belongs to the Pacman-based Linux family. It is a light weighted OS for daily use and could even be used by professionals. It was first released in March 2002. It is a beginner-friendly Linux Operating System. Features of Arch Linux: Minimalist approach:
4 min read
Neofetch In Linux – Snap cool screenshots of your Linux
Neofetch is a fancy, highly customizable, and aesthetic command-line system information screenshot utility tool. Written in the Bash scripting language, it works inside a terminal window, on triggering up the command it by default displays the operating system, software, and hardware of your system on the right side of the column alongside an ASCII
4 min read
Basic CentOS Linux Commands in linux
CentOS is a free and open-source operating system that aims to provide a stable reliable, and community-supported platform for servers and other enterprise applications. In this article, we will be covering CentOS Linux basics commands and functions of CentOS and also we will look into the advanced commands. These CentOS commands allow you to manag
3 min read
Linux on Azure – Linux Distributions
Azure, the cloud computing platform from Microsoft, offers a playground for deploying and managing your Linux-based operating systems. Think of it as a canvas of boundless resources, security, and scalability, painted onto which you can unleash the boundless creativity and flexibility of Linux. This powerful synergy unlocks a world of opportunity,
10 min read
Function Call Stack in C
A function in C is a set of code that performs a specific task and can be used whenever needed just by calling it. But how the function call works and how the data of the function is stored in the memory is an area of interest for a better understanding of the concepts such as recursion. What is a Call Stack in C? A call stack in C is the stack tha
4 min read
How much Stack size required for BIOS interrupt call?
Stack: It is a linear data structure that follows the LIFO( Last In First Out ) order for performing the operations. BIOS: It provides a set of instructions and is responsible for booting the computer. The BIOS performs all the tests needed at startup time.Stack size required for bios interrupt calls?1) For No interrupts generated in task Formula F
2 min read
Fork Function Call
In this article, we are going to see the fork function call in detail with the help of an example. A function call is an operating system call that is used to create a copy of a process which is also called a child process. This function call is used in a system that supports multitasking. Purpose of Fork()At its core, a function call is a fundamen
3 min read
Difference Between ISR and Function Call
In embedded systems programming, or when working with microcontrollers, one has to distinguish between the terms "Interrupt Service Routine" and "function call". Generally, ISRs and function calls are used to execute some blocks of the code. But, they serve different purposes and, in some cases, may run under different conditions. In this article,
7 min read
proc file system in Linux
Proc file system (procfs) is a virtual file system created on the fly when the system boots and is dissolved at the time of system shutdown. It contains useful information about the processes that are currently running, it is regarded as a control and information center for the kernel. The proc file system also provides a communication medium betwe
4 min read
Taking Linux System Snapshots with Timeshift
Timeshift is a Linux application that is built for providing functionality to restore your system just like when you restore a Windows system. Timeshift makes snapshots of your system in regular intervals which are further used at the time of restoration or undo all changes in the system. Each Snapshot taken by Timeshift is a complete system backup
3 min read
Groups in Linux System Administration
Each group in a Linux system is uniquely identified by a group identification number or GID. All the information listing groups in a system are stored in /etc/group file. The hashed passwords for groups are stored in /etc/gshadow file. Every user has a primary user group and zero or more supplementary groups. On login, the group membership is set t
2 min read
Users in Linux System Administration
Users are accounts that can be used to login into a system. Each user is identified by a unique identification number or UID by the system. All the information of users in a system are stored in /etc/passwd file. The hashed passwords for users are stored in /etc/shadow file. Users can be divided into two categories on the basis of the level of acce
3 min read
What is Linux System Administration?
Linux is an operating system, or a kernel created by Linus Torvalds with other contributors. It was first released on September 17, 1991. The main advantage of Linux is that it is distributed under an open-source license, which means programmers can use the Linux Kernel to design their own custom operating systems. Most Linux code is written in C P
5 min read
Compare file system in Windows and Linux
File System in Linux : Linux supports more than 12 file systems with NFS technology. When Linux (that is, operating system code) is linked, the default file system option needs to be specified. other file systems can be called dynamically depending on requirements. Ext file system is the most popular option. It is similar to the Berkeley file syste
3 min read
Getting System and Process Information Using C Programming and Shell in Linux
Whenever you start a new process in Linux it creates a file in /proc/ folder with the same name as that of the process id of the process. In that folder, there is a file named "status" which has all the details of the process. We can get those Process Information Through shell as follows: cat /proc/1/status As can be seen, it displays most of the i
2 min read
Beginner's Guide to Linux System Administration
A Linux System Administrator manages the operations such as maintaining proper software, observing them, and even taking care of backup and hardware systems. It is recommended that before reading this article please go through the article What is Linux System Administration. Here we have some basics of Linux System Administration. Some Basic Config
5 min read
Basic System Controls with Terminal in Linux
Sometimes some of the basic services of the system stop working or starts malfunctioning. And it becomes really difficult to solve the problem through Graphical User Interface so here is the list of Terminal Command to solve the problem and to control the basic services manually. Installing the required packages To control the basic system services
2 min read
How to Setup VPN on Ubuntu Linux System for IP Spoofing Using windscribe?
In simple words, IP Spoofing can be stated as “Hiding your Systems IP address from others”. It is essentially a technique used by hackers to gain unauthorized access to Computers. Concepts of IP Spoofing was initially discussed in academic circles as early as 1980. IP Spoofing types of attacks had been known to Security expert on the theoretical le
3 min read
Linux - Installing Tripwire IDS (Intrusion Detection System)
IDS(Intrusion detection system) is a software application that monitors your system and checks whether any malicious activity is found or not and reports that to the administrator. Security is a big issue for any Linux administrator, so today we are going to discuss how you can install Tripwire IDS on Linux, Tripwire is a popular open-source Linux
2 min read
Article Tags :