0% found this document useful (0 votes)
32 views

Le-6 System Calls

This document discusses process management commands and system calls in Linux. It describes commands like ps, top, pstree, nice, and renice for managing and viewing processes. It then explains that system calls provide an interface between processes and the operating system to request resources. Common system call categories are described like process management, file management, networking, devices, and system information calls. Specific process and file management system calls like fork(), exec(), open(), read(), and write() are outlined.

Uploaded by

Harshit Anand
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)
32 views

Le-6 System Calls

This document discusses process management commands and system calls in Linux. It describes commands like ps, top, pstree, nice, and renice for managing and viewing processes. It then explains that system calls provide an interface between processes and the operating system to request resources. Common system call categories are described like process management, file management, networking, devices, and system information calls. Specific process and file management system calls like fork(), exec(), open(), read(), and write() are outlined.

Uploaded by

Harshit Anand
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/ 9

OPERATING SYSTEM & LINUX

PROGRAMMING
PROCESS MGMT COMMANDS &
SYSTEM CALLS
PROCESS MANAGEMENT COMMANDS

•ps–Displays the current processes.


•top –Shows top running processes with their PID, Process user, priority, nice
value, %CPU, %memory consumed by the process.
•pstree–Displays running processes hierarchically arranged in tree format.
Parent and child processes can be identified. Root of the tree is either initor
the process with the given pid.
•nice –Used to assign particular priority, thus giving process more or less
CPU time than other processes. Priority values ranges from -20 to 19. Lower
the nice value, higher the priority. Default nice value is 0.
•renice–Used to change priorities of already running processes.
•kill –This command terminates running processes. kill pid
System Call
• A system call is a procedure that provides the interface between a process
and the operating system.
• It is the way by which a computer program requests a service from the
kernel of the operating system.
• In Linux, making a system call involves transferring control from
unprivileged user mode to privileged kernel mode; the details of this
transfer vary from architecture to architecture.
• When a program requires a system resource, it sends a request for that
resource to the kernel by making a system call.
For example : Suppose a text editor is executed to open a file and make
changes. Then the text editor will send system calls like open(),write() and
close().
Types of System calls in Linux
The ;system calls are divided into five categories :
• Process management system calls
• File management system calls
• Device management system calls
• Network management system calls
• System information system calls
Process Management System Calls
• Process Control -This system calls perform the task of process creation,
process termination, etc. Process management is a way to handle multiple
processes and plays a crucial role in multitasking.
• Some common process management calls are :
fork() - As the name suggests, this creates a child process from the
parent process which results in the exact same process except for some
values like PID and parent PID.
exec() - This system call replaces the current process image with the
new image and it is used when you want to run a different program from the
current process.
exit() - This system call terminates the current process and returns the
resources acquired by that process (which was terminated recently) to the
system.
File Management System Calls

The filesystem calls in Linux facilities other programs to interact with


the filesystem.
Some of the popular system calls :
Open()-It is used to open the file.
Read()- This system call can be used to read data from a wide range of
data types including regular files, and special files like pipes and
sockets, and it can also read from device files like /dev directory.
Write()- It is used to modify files, generate log files, reports, etc.
Close()- This will close the file and save the changes to the disk
Network System calls
The network system calls are used to manage networks, send/receive data,
resolve network addresses, etc.
Some of the system calls are :
Socket()- This system call is used to create sockets which are endpoints for
communication.
Bind()- It is used to bind a socket to the specific address and port on the local
network.
Send()- it is used to send data over the socket.
Recv()- It is used to receive data over the socket.
Connect()- It establishes the connection to the external network endpoint.
Device Management System calls
The device management system calls are used to manage devices that
are connected to your system. The device management system calls
provides a way to read/write data, and control and configure those
devices.
Some of common system calls are :
Ioctl()- It is used to send control commands to the connected devices.
mmap()- It is used to map the partition of a file into the memory of the
own process. This results in direct access to the memory-mapped data
as if it was a part of the process's own memory.
System Information System Calls
The system information system calls are used to get various kinds of
information such as system resources, system time, system
configuration, etc.
Some of the common system information calls are :
getpid()-Gets the PID(process ID) of the current process.
getppid()-Gets the parent PID of the current process.
getuid()-Gets the User ID of the current process.
getgid()-Gets the GID(group ID) of the current process.

You might also like