


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 4
This page cannot be seen from the preview
Don't miss anything!



(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
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);