System Calls
System calls are the interface
between the user-level applications and the operating system. They provide a
way for programs to request services from the operating system, such as
creating a process, reading a file, or accessing the network.
When a system call is made, it's
handled by the kernel (the core of the operating system). The kernel executes
the request on behalf of the user-level application, as it has the necessary
permissions to interact directly with the hardware and system resources.
There are several types of system
calls, typically falling into these major categories:
- Process Control: These system calls can
create, terminate, or end processes. Examples include fork(), exit(), and
wait().
- File Management: These system calls are used
to read, write, open, and close files. Examples include open(), read(),
write(), and close().
- Device Management: These system calls are
used to request access to devices, read or write to devices, and release
devices. Examples include ioctl(), read(), and write().
- Information Maintenance: These system calls
are used to get or set system data. They can be used to get the system
time, get process or system information, and set process or system
information. Examples include time(), getpid(), and setuid().
- Communication: These system calls create,
send, receive, and manage communication between processes. Examples
include pipe(), socket(), send(), and receive().
In general, system calls allow
user-level applications to interact with the system and its resources in a
controlled and safe manner, without requiring the application to have direct
access to the hardware or other low-level resources.
Types of system calls
System calls are the interfaces
between a process and the operating system. They provide the means for a user
program to request services of the operating system. Here are the main types of
system calls:
- Process Control System Calls: These are used
for controlling processes. Examples include fork(), exit(), wait(),
exec(), getpid(), etc. They are used for operations such as
process creation, process termination, and process attributes control.
- File Manipulation System Calls: These are
used for file management. Examples include open(), close(), read(),
write(), link(), unlink(), seek(), stat(),
etc. They are used for operations such as file creation, deletion,
opening, closing, reading, and writing.
- Device Management System Calls: These are
used for device manipulation. Examples include ioctl(), read(),
write(), etc. They are used for operations like requesting a
device, releasing a device, reading, writing, repositioning, etc.
- Information Maintenance System Calls: These
are used for system data operations. Examples include getpid(), getuid(),
alarm(), sleep(), time(), chmod(), etc. They
are used for operations such as setting/getting process attributes,
setting/getting file attributes, setting/getting system attributes, etc.
- Communication System Calls: These are used
for interprocess communication. Examples include pipe(), shmget(),
shmctl(), semget(), semop(), msgget(), msgsnd(),
msgrcv(), etc. They are used for operations like creating,
destroying communication connection, sending/receiving messages,
transferring status information, etc.