Open In App

Different Types of System Calls in OS

System calls are interfaces provisioned by the operating system to allow user-level applications to interact with low-level hardware components & make use of all the services provided by the kernel, which is a core component and the heart of an operating system that manages all the hardware and the services provided by the OS. These system calls are essential for every process to interact with the kernel and leverage the services provided by it.

System calls are basically an interface between a process and the operating system. And they’re the only way to switch from user mode to kernel mode.



Pre-requisite: Introduction to System Calls

Types of System Calls

Services provided by an OS are typically related to any kind of operation that a user program can perform like creation, termination, forking, moving, communication etc. Similar types of operations are grouped into one single system call category. System calls are classified into the following categories :



Types of System Calls

1. File System Operations

These system calls are made while working with files in OS, File manipulation operations such as creation, deletion, termination etc.

Algorithm for Reading a File:

algorithm read

input: user file descriptor, address of buffer in user process, number of bytes to read

output: count of bytes copied into user space

{

get file table entry from user file descriptor;

check file accessibility;

set parameters in u area for user address, byte count, I/O to user;

get inode from file table;

lock inode;

set byte offset in u area from file table offset;

while(count not satisfied)

{

convert file offset to disk block(algorithm bmap);

calculate offset into block, number of bytes to read;

if(number of bytes to read is 0)

break;

read block (algorithm breada if with read ahead, algorithm bread otherwise);

copy data from system buffer to user address;

update u area fields for file byte offset, read count, address to write into user space;

release buffer;

}

unlock inode;

update file table offset for next read;

return(total number of bytes read);

}

2. Process Control

These types of system calls deal with process creation, process termination, process allocation, deallocation etc. Basically manages all the process that are a part of OS.

3. Memory Management

These types of system calls deals with memory allocation, deallocation & dynamically changing the size of a memory allocated to a process. In short, the overall management of memory is done by making these system calls.

4. Interprocess Communication (IPC)

When two or more process are required to communicate, then various IPC mechanism are used by the OS which involves making numerous system calls. Some of them are :

5. Device Management

The device management system calls are used to interact with various peripherial devices attached to the PC or even the management of the current device.

Conclusion

System calls are a great way to take full advantage of the services provided by the kernel. Every system call is made in background completely hidden from the user. And every action you perform in a computer like creating, deleting, copy and other operations have many number of system calls done in background which are hidden from the user for simplicity.

FAQs on System Calls

Q.1: What is the purpose of System Calls?

Answer:

The purpose of the system calls is to allow user-level applications access of the services provided by the kernel. The user apps do not have the privelege to perform operations, so they make system calls which further requests a kernel to provide a specific service.

Q.2: How do device management System Calls work?

Answer:

Device management system calls work by allowing a certain process or a device interact and get access to other hardware resources and perform various operations.

Q.3: What is user mode and kernel mode?

Answer:

User mode and kernel modes are two different privilege modes of a Computer System, that separates the execution of operations by the user applications and the kernel on hardware. This separation provides security, stability, and a level of control over system resources.

Q.4: What happens when a System Call is executed?

Answer:

When a system call is executed, a context switch occurs and the computer system switches from user mode to kernel mode and now the kernel performs the desired operation.

Q.5: What is a software interrupt?

Answer:

A software interrupt is a mechanism through which the OS performs a context switch and transition from user mode to kernel mode. A software interrupt use is not limited only to the system calls but it can also be made when a high priority task is required to be executed by the CPU.


Article Tags :