OS provides a set of functions that can be called by user programs to request for OS services. These functions are called system calls. System calls provide an interface to the services made available by an operating system. It is the mechanism used by an application program to request service from the operating system.
System calls often use a special machine code instruction which causes the processor to change mode. This allows the OS to perform restricted actions such as accessing hardware devices or the memory management unit.
To access the hardware resources system calls run in kernel mode. They can be called by executing a special instruction (trap or software interrupt) which causes processor to switch to the kernel mode and jump to a previously defined location in the kernel. And when the system call finishes, processor returns to the user program and runs in user mode.
System calls occur in different ways. It depends on the computer in use. Often, more information is required than simply knowing about the identity of the desired system call. The exact type and amount of information vary according to the particular operating system call. For instance, to get input, we may need to specify the file or device to use as the source, as well as the address and length of the memory buffer into which the input should be read.
Steps in making system calls:
There are three general ways to pass the parameters to the operating system. One of them is to pass the parameters in the registers, it is also the simplest one. In some cases, the parameters are generally stored in a block, or table in memory and the address of the block is passed as a parameter in a register. This is the approach taken by Linux and Solaris. Parameters can also be placed using stack (by pushing or by popping of parameters). Some operating system prefer the block or stack method as they do not limit the number or length of the parameters being passed.
Types of System Calls
There are mainly five types of system calls: process control, file manipulation, device manipulation, information maintenance, and communications.
1. Process control
- end, abort
- load, execute
- create process, terminate process
- get process attributes, set process attributes
- wait for time
- wait event, signal event
- allocate and free memory
2. File management
- create file, delete file
- open, close
- read, write, reposition
- get file attributes, set file attributes
3. Device management
- request device, release device
- read, write, reposition
- get device attributes, set device attributes
- logically attach or detach devices
4. Information maintenance
- get time or date, set time or date
- get system data, set system data
- get process, file, or device attributes
- set process, file, or device attributes
- create, delete communication connection
- send, receive messages
- transfer status information
- attach or detach remote devices
These are the list of system calls available for OS
– Sagar Sharma