The system calls is a mechanism that allows the user program to invoke the kernel that lets the user program interact with the operating system. The number of system calls depends upon the kind of operating system you are using.
In this section further, we will be discussing the type of system calls that the user program uses to interact with the operating system.
Types of System Calls
- Process control
- File Manipulation
- Device Manipulation
- Information Maintenance
Several system calls need to control the processes in the operating system. The first required system call creates a process. Once the process is created, then it must be loaded to the main memory for execution.
Once the process is created, it will require some time to finish its execution; the amount of time it needs to wait is wait time. Or the process must be waiting for a certain event to occur, i.e. wait event. The time at which the event would occur must be signalled with the signal event.
The most used system calls for file manipulation are creating the file and deleting the file. For file manipulation, the system calls either use the name of the file, or it may use any of the file’s attributes. The created file also needs to be opened, read, write or reposition and after the usage, the file needs to be closed.
The same set of operations can also be used for directories in case we are using directory structures for organizing files. File manipulation system calls such as get file attribute and set file attribute. Moreover, it is used to determine or reset the values of attributes of files or directories. The attributes to be determined or rest are file name, its type, accounting information, protection code etc.
A process requires to held several resources for its execution. The resource can be physical devices such as disks and drives or virtual devices such as files. For exclusive use, the process must first request for the device. After the completion of the task, it must release the resource. This is similar to the open and close system call we use in file management.
Some information maintenance system calls are used for transferring information between the user program and the operating system. Some information maintenance system calls return system information such as the amount of free memory, your system configuration, the number of current users of the system, etc.
The information maintenance system all dumps memory and stores the information of the application or system before it gets crashes. So, the dump memory system call helps the programmers or developers in debugging the program.
Must Read: Thread in Operating System
Communication System Calls
The two types of interprocess communication, i.e., the message-passing model and the shared memory model. In the message-passing model, the two processes communicate with each other to exchange information. The communicating processes may be on the same system or on two different systems connected by the communication network.
To start communication, there has to be an open between the two communicating processes. Also, the process that wants to send the message to the other process must know the name of the latter process. For that, it can use two elements, such as the computer name host_id to which the latter process belongs and the name of the process, i.e., process_id.
The system calls used to get the host_id, and process_id get hostid and get processid. Further, these identifiers are passed to the open connection, and close connection system calls. The recipient process permits the connection with the accept connection system call. The information is exchanged using the read message and writes the message system call. Finally, the connection is terminated with a close connection system call.
In the shared-memory model, to gain access to regions held by other processes, the client process uses shared memory to create and shared memory attach system call. Usually, the operating system doesn’t allow a process to access the resources held by other processes. But, the shared memory model removes this restriction.
Must Read: Process Scheduling
Protection System Calls
Protection is a technique that controls access to system resources. As of today’s scenario, computers, i.e. from servers to PDAs all over the world, are connected using networking. Further, the internet needs to be concerned about protection.
The system calls providing protection to the system resources are get permission and set permission, thereby controlling the access to system resources such as files and disk. Further, the allow user and deny user system call only let the authenticated user access the system resources.
With all these systems calls, the user program can interact with the operating system.