1. Overview

In this tutorial, we’ll learn about system calls and their types.

2. What Is a System Call?

System calls are mechanisms that provide the operating system’s services to computer programs. Computer programs use system calls to request a service from the operating system’s kernel. Moreover, if a program requires a resource from the operating system, it needs to make a system call.

3. Types of System Calls

System calls provide many services to computer programs. They are categorized into five categories based on the services that they provide:

3.1. Process Control

Process control system calls are used to create and manage processes. For example:

  • fork: a system call that creates a child process. The calling process will be the parent
  • exit: it terminates the calling process
  • exec: it’s used to execute a file, and it replaces the current process image with a new process image
  • wait: suspends execution of the current process until one of its children terminates

3.2. File Management

File management system calls are used to manipulate files. Some of them are:

  • open: opens a file specified by pathname. If the file doesn’t exist, it can create it.
  • read: reads from a file descriptor into a buffer
  • write: writes to a file descriptor from a buffer
  • close: closes a file descriptor

3.3. Device Management

Device management system calls are used to manipulate or manage devices. For example, ioctl (input/output control) controls a device by sending a device-dependent request code.

3.4. Information Maintenance

Information maintenance system calls are used to manage and transfer information between the operating system and computer programs. For example, getpid is a system call that returns the process id (PID) of the calling process when it’s called by a program.

3.5. Communications

They’re used for communication between different processes. For example, pipe is a system call that creates a pipe, a unidirectional data channel that connects two processes.

4. Summary

In this tutorial, we learned about system calls and their types.

Comments are closed on this article!