Creating and Managing Processes in Linux, Schemes and Mind Maps of Computers and Information technologies

This lab manual covers the fundamental concepts of process creation and management in the Linux OS. It introduces the fork() system call, exec(), sleep(), and wait() for process synchronization. The lab exercises provide hands-on experience in writing programs to create and manage processes using Ubuntu and Vim. A valuable resource for students studying operating systems, computer science, or software engineering.

Typology: Schemes and Mind Maps

2021/2022

Uploaded on 06/23/2022

Hamid133
Hamid133 🇺🇸

4 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Bahria University, Lahore Campus
Department of Computer Sciences
Lab Manual 05
(Spring 2022)
Course: Operating System Lab Date:
Course Code: CSL - 320 Max Marks: 20
Faculty’s Name: Lab Engineer: Sarah Chaudhry
Name:____________________________________ Enroll No: _______________________
Objective(s):
To write a program to create a process in LINUX.
To understand exec process.
To create child with sleep and wait command.
To understand getpid( ) and getppid( ).
Tool(s) used:
Ubuntu, VIM Editor
FORK( ) SYSTEM CALL:
The purpose of fork() is to create a new process, which becomes the child process of the caller.
After a new child process is created, both processes will execute the next instruction following the
fork() system call. Therefore, we have to distinguish the parent from the child.
The new child process spawned by fork is an identical process to the parent except that has a
new system process ID. The process is copied in memory from the parent and a new process
structure is assigned by the kernel. The return value of the function is which discriminates the
two threads of execution. A zero is returned by the fork function in the child's process.
The fork operation creates a separate address space for the child. The child process has an
exact copy of all the memory segments (contents) of the parent process, except new process
ID.
pf3
pf4

Partial preview of the text

Download Creating and Managing Processes in Linux and more Schemes and Mind Maps Computers and Information technologies in PDF only on Docsity!

Bahria University, Lahore Campus

Department of Computer Sciences

Lab Manual 05

(Spring 2022) Course: Operating System Lab Date: Course Code: CSL - 320 Max Marks: 20 Faculty’s Name: Lab Engineer: Sarah Chaudhry Name:____________________________________ Enroll No: _______________________ Objective(s):  To write a program to create a process in LINUX.  To understand exec process.  To create child with sleep and wait command.  To understand getpid( ) and getppid( ). Tool(s) used: Ubuntu, VIM Editor

FORK( ) SYSTEM CALL:

The purpose of fork() is to create a new process, which becomes the child process of the caller. After a new child process is created, both processes will execute the next instruction following the fork() system call. Therefore, we have to distinguish the parent from the child. The new child process spawned by fork is an identical process to the parent except that has a new system process ID. The process is copied in memory from the parent and a new process structure is assigned by the kernel. The return value of the function is which discriminates the two threads of execution. A zero is returned by the fork function in the child's process. The fork operation creates a separate address space for the child. The child process has an exact copy of all the memory segments (contents) of the parent process, except new process ID.

Resources which are duplicated: The environment, resource limits, controlling terminal, current working directory, root directory, signal masks and other process resources are also duplicated from the parent in the forked child process. PID → Process ID PPID → Parent Process ID Flow of Execution:

GETPID( ) and GETPPID( ) FUNCTIONS getppid() : returns the process ID of the parent of the calling process. pid_t getppid(void); getpid() : returns the process ID of the calling process. pid_t getpid(void);