0% found this document useful (0 votes)
6 views3 pages

System Calls Overview

System calls are mechanisms that allow user-level applications to request services from the operating system's kernel, enabling access to resources like files and hardware. They are categorized into types such as process control, file management, device management, memory management, and inter-process communication. System calls are crucial for OS functionality, providing abstraction, security, and efficient resource management.

Uploaded by

prabanshan2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

System Calls Overview

System calls are mechanisms that allow user-level applications to request services from the operating system's kernel, enabling access to resources like files and hardware. They are categorized into types such as process control, file management, device management, memory management, and inter-process communication. System calls are crucial for OS functionality, providing abstraction, security, and efficient resource management.

Uploaded by

prabanshan2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

System Calls and Their Importance

## System Call - Overview


A system call is a mechanism used by programs to request services
from the operating system's kernel. Since user-level applications
cannot directly interact with hardware or execute privileged
operations, they rely on system calls to access resources like files,
memory, processes, and hardware devices.

For example, when you open a file, create a process, or allocate


memory, the program makes a system call, and the OS handles the
request.

## Types of System Calls

### 1. Process Control System Calls


Used for creating, managing, and terminating processes.
- fork() - Creates a new process (child process).
- exec() - Replaces the current process with a new program.
- wait() - Waits for a child process to complete execution.
- exit() - Terminates a process.
- kill() - Sends signals to a process to terminate or change its
behavior.

Example: When you run a program like gcc myfile.c, the OS creates a
process using fork() and executes it using exec().

### 2. File Management System Calls


Used for file-related operations.
- open() - Opens a file.
- read() - Reads data from a file.
- write() - Writes data to a file.
- close() - Closes an opened file.
- lseek() - Moves the file pointer to a specific position.
- stat() - Retrieves file metadata.

Example: When you open a document in a text editor, the OS makes


an open() system call.

### 3. Device Management System Calls


Used to manage hardware devices.
- ioctl() - Configures a device.
- read() - Reads from a device.
- write() - Writes data to a device.
- close() - Releases the device after use.

Example: When you print a document, the OS sends the data to the
printer using a write() system call.

### 4. Memory Management System Calls


Used for memory allocation and management.
- brk() - Expands or shrinks heap memory.
- mmap() - Maps files into memory.
- shmget() - Allocates shared memory.
- shmat() - Attaches shared memory to a process.

Example: When a program needs more memory dynamically (like


arrays in C), it uses malloc(), which internally calls brk().

### 5. Communication System Calls (IPC - Inter-Process


Communication)
Used for data exchange between processes.
- pipe() - Creates a pipe for communication.
- msgget() - Creates a message queue.
- send() / recv() - Used in network communication.
- shmget() - Creates shared memory.
- socket() - Creates a network socket.

Example: When a web browser communicates with a server, it uses


socket() calls to send and receive data.

## Importance of System Calls


1. Abstraction & Security - Prevents direct access to hardware and
sensitive resources.
2. Process Management - Enables process creation, termination, and
synchronization.
3. File Operations - Allows programs to read, write, and modify files
efficiently.
4. Resource Management - Helps in memory allocation and
deallocation.
5. Hardware Interaction - Enables communication with devices like
printers, keyboards, and storage.
6. Network Communication - Supports data exchange between
systems over networks.

## Conclusion
System calls are essential for OS functionality as they bridge user
applications and system resources. Without system calls,
applications wouldn't be able to perform even basic tasks like reading
files or running programs.

You might also like