0% found this document useful (0 votes)
49 views15 pages

Bushramemon - 2075 - 4326 - 1 - Lecture - Process System Calls

The document discusses process system calls in operating systems, which allow programs to request services from the OS related to process creation, termination, identification, control, synchronization, IPC, monitoring and management, and error handling. Key system calls are described for each area like fork(), exec(), exit(), wait(), getpid(), nice(), pipes, and monitoring tools. Process system calls are fundamental for allowing interaction with processes and managing their execution in an organized way.

Uploaded by

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

Bushramemon - 2075 - 4326 - 1 - Lecture - Process System Calls

The document discusses process system calls in operating systems, which allow programs to request services from the OS related to process creation, termination, identification, control, synchronization, IPC, monitoring and management, and error handling. Key system calls are described for each area like fork(), exec(), exit(), wait(), getpid(), nice(), pipes, and monitoring tools. Process system calls are fundamental for allowing interaction with processes and managing their execution in an organized way.

Uploaded by

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

Process System Calls

OPERATING SYSTEM
Objective:
Understand the significance of process system calls in Operating Systems. System calls provide a
way for programs to request services from the operating system.
1. Process creation
2. Process termination
3. Process identification
4. Process control
5. Process synchronization
6. IPC
7. Process monitoring and management
8. Error handling
Introduction
Processes are fundamental in operating systems.
Process system calls allow interaction with processes.
In this lecture, we'll explore process-related system calls.
Process Creation
Definition:
Process creation is the act of generating a new process in an operating system. It
allows a program to create child processes dynamically. System calls to create
processes:
System call: fork(), vfork(), exec().
Explanation:
•fork(): A system call used to create a new process, called the child process, which is a
copy of the current process (the parent).
•vfork() system call, child and parent process share same address space.
•exec(): Replaces the current process with a new program
•Child and parent processes: Child inherits properties, but have distinct memory space.
Process Termination
Definition:
Process termination involves ending a process's execution in an orderly or abrupt manner,
freeing up system resources.
System calls: exit(), wait(), abort().
Explanation:
exit(): Ends a process, and reports status to parent.
wait(): Allows a parent process to wait until its child processes have terminated.
abort(): Abnormally ends a process.
Process Identification
Definition:
Process identification is the act of obtaining information about processes, including their unique
identifiers.
Explanation:
Every process has a unique Process ID (PID).
getpid(): A system call that returns the of the current process ID (PID) of the calling process.
getppid(): A system call that returns the parent process's PID.
Process Control
Definition:
Process control involves managing processes, which can include signaling processes and adjusting
their priorities.
System calls: nice(), getpriority(), setpriority().
Used to control the execution attributes of processes, such as priority.
Explanation:
kill(): A system call for sending signals to processes, allowing for the control and communication
between processes.
nice(): A system call for adjusting a process's priority, affecting its scheduling in a multi-tasking
environment.
pause(): A system call that suspends the calling process until it receives a signal.
1.nice()

Purpose: Modifies the scheduling priority of the current process.


Usage:
#include <unistd.h>
int nice(int incr);
Description: The `nice()` function changes the priority of the current process by adding the
value of `incr` to its current priority. A positive `incr` makes the process less favorable (i.e., it
may get less CPU time), while a negative `incr` makes it more favorable.
2. getpriority():

Purpose: Fetches the current scheduling priority for a process, process group, or user.
Usage:
#include <sys/resource.h>
int getpriority(int which, id_t who);

Description: The `getpriority()` function retrieves the nice value (priority) for a specified set of
processes. The `which` parameter determines the set of processes: `PRIO_PROCESS` (a single
process), `PRIO_PGRP` (all processes in a process group), or `PRIO_USER` (all processes for a
user). The `who` parameter specifies the ID (process ID, group ID, or user ID) depending on the
value of `which`.
3.setpriority():

Purpose: Sets the scheduling priority for a process, process group, or user.
Usage:
#include <sys/resource.h>
int setpriority(int which, id_t who, int prio);

Description: The `setpriority()` function sets the nice value (priority) for a specified set of
processes, similar to `getpriority()`. The parameters have the same meanings. It sets the priority
to `prio` for the specified set of processes.
Process Synchronization
Definition:
Process synchronization is the coordination of activities or tasks between different processes to
prevent conflicts or ensure orderly execution.
Explanation:
wait(): A system call used to synchronize a parent process by waiting for child processes to
complete their execution.
System calls: sem_init(), sem_wait(), sem_post(), etc.
Mechanisms: Semaphores, mutexes, condition variables.
Semaphores: A synchronization mechanism that allows processes to coordinate access to
shared resources in a controlled manner. Ensures processes don't interfere with each other.
IPC (Inter-Process Communication)
Definition:
IPC involves communication between processes to exchange data or coordinate actions.
Explanation:
Mechanisms for processes to communicate and synchronize their actions.
System calls: pipe(), msgget(), msgsnd(), msgrcv().
Methods: IPC mechanisms like Pipes, message queues, shared memory, sockets.
pipe(): A system call that creates a unidirectional communication channel between processes
for data transfer.
Process Monitoring and Management
Definition:
Process monitoring and management involve tracking, controlling, and overseeing the execution of
processes in the system.
System calls: ps, top, kill, pgrep.
Explanation:
ps: A command that displays information about running processes, including their status, resource
usage, and more.
top: A real-time system monitoring tool that provides insights into the performance and resource
usage of processes.
kill: Send signals to processes. E.g., termination, pausing.
Monitoring tools provide insights into process states, CPU usage, memory usage, etc.
Error Handling
Definition:
Error handling refers to the techniques and mechanisms used to deal with errors or exceptional
situations in the context of processes and system calls.
Explanation:
System calls often return -1 or NULL to indicate errors.
perror(): Print a description of the last error.
errno: Global variable set by system calls to indicate the error.
Implementing Process System Calls

You might also like