Expt 3_COS_008
Expt 3_COS_008
Expt No: 3
Title: To study system calls.
COs to be achieved:
CO 1: Explain the fundamental concepts of operating system
Theory:
System Calls Provide the Interface between a process and the OS.
System calls are usually made when a process in user mode requires access to a resource.
Then it requests the kernel to provide the resource via a system call.
System calls are required in the following situations −
1) If a file system requires the creation or deletion of files.
2) Reading and writing from files also require a system call.
3) Creation and management of new processes.
4) Network connections also require system calls. This includes sending and receiving packets.
5) Access to a hardware devices such as a printer, scanner etc. requires a system call.
The system call interface is a fundamental mechanism that allows user applications to interact with
the operating system. It provides a controlled means for programs to request services from the
kernel, such as file operations, process management, and inter-process communication. When a user
application needs to perform an operation that requires higher privileges, such as reading from a file
or allocating memory, it makes a system call to request the operating system's assistance. The
system call interface acts as a bridge between user space and kernel space. Applications use a set of
predefined system call functions, which are implemented by the operating system. These system
calls are typically invoked via library functions that handle the details of switching from user mode
to kernel mode, ensuring that the application’s request is processed securely and efficiently. The
operating system then performs the requested operation on behalf of the application and returns the
result. This interface is crucial for maintaining system stability and security, as it enforces
boundaries between user applications and the core system components. By providing a controlled
and monitored way for applications to access hardware and system resources, the system call
interface helps prevent unauthorized access and potential system crashes.
System calls can be categorized into several types based on the services they provide to applications.
File management system calls handle operations related to files and directories, such as opening,
reading, writing, and closing files. Examples include `open()`, `read()`, `write()`, and `close()`.
These calls allow applications to interact with the file system and perform tasks like creating or
modifying files.
Process management system calls are concerned with creating, terminating, and controlling
processes. They include `fork()`, which creates a new process, `exec()`, which replaces the process
image with a new program, and `wait()`, which allows a process to wait for its child processes to
complete. These calls are essential for managing the execution of programs and coordinating
between different processes.
Memory management system calls are used to allocate and manage memory resources. Examples
include `mmap()`, which maps files or devices into memory, and `brk()`, which adjusts the end of
the data segment of a process. These calls help applications request and manage memory
dynamically.
Device management system calls allow applications to interact with hardware devices. These calls
include `ioctl()`, which is used to configure device parameters, and various calls for reading and
writing device data. They enable communication between user applications and hardware
peripherals.
Information management system calls provide information about system resources and process
status. Examples include `getpid()`, which retrieves the process ID, and `stat()`, which provides file
status information. These calls help applications obtain necessary details about the system
environment and resources.
Overall, these types of system calls form the core interface through which user applications request
and manage system resources and services.
Conclusion: