


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
Process creation, Process management in UNIX, Sample codes, Process termination, Process managemant in Linux, System calls, Operations in processes, Process tree. Above mentioned are key points of this lecture handout. Virtual University handout for introduction to operating system are in detail and explanatory.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Operating Systems--- [CS-604] Lecture No. 6
Operating Systems Concepts, Chapter 4 UNIX/Linux manual pages for the fork()system call
Process creation and termination Process management in UNIX/Linux— system calls: fork, exec, wait, exit Sample codes
The processes in the system execute concurrently and they must be created and deleted dynamically thus the operating system must provide the mechanism for the creation and deletion of processes.
A process may create several new processes via a create-process system call during the course of its execution. The creating process is called a parent process while the new processes are called the children of that process. Each of these new processes may in turn create other processes, forming a tree of processes. Figure 6.1 shows partially the process tree in a UNIX/Linux system.
Figure 6.1 Process tree in UNIX/Linux
In general, a process will need certain resources (such as CPU time, memory files, I/O devices) to accomplish its task. When a process creates a sub process, also known as a child, that sub process may be able to obtain its resources directly from the operating system or may be constrained to a subset of the resources of the parent process. The parent may have to partition its resources among several of its children. Restricting a
process to a subset of the parent’s resources prevents a process from overloading the system by creating too many sub processes. When a process is created it obtains in addition to various physical and logical resources, initialization data that may be passed along from the parent process to the child process. When a process creates a new process, two possibilities exist in terms of execution:
A process terminates when it finishes executing its final statement and asks the operating system to delete it by calling the exit system call. At that point, the process may return data to its parent process (via the wait system call). All the resources of the process including physical and virtual memory, open the files and I/O buffers – are de allocated by the operating system. Termination occurs under additional circumstances. A process can cause the termination of another via an appropriate system call (such as abort). Usually only the parent of the process that is to be terminated can invoke this system call. Therefore parents need to know the identities of its children, and thus when one process creates another process, the identity of the newly created process is passed to the parent. A parent may terminate the execution of one of its children for a variety of reasons, such as: The child has exceeded its usage of some of the resources that it has been allocated. This requires the parent to have a mechanism to inspect the state of its children. The task assigned to the child is no longer required.
creates an exact memory image of the parent process and returns 0 to the child process and the process ID of the child process to the parent process.
Figure 6.3 Semantics of the fork system call
After the fork() system call the parent and the child share the following: Environment Open file descriptor table Signal handling settings Nice value Current working directory Root directory File mode creation mask (umask) The following things are different in the parent and the child: Different process ID (PID) Different parent process ID (PPID) Child has its own copy of parent’s file descriptors The fork() system may fail due to a number of reasons. One reason maybe that the maximum number of processes allowed to execute under one user has exceeded, another could be that the maximum number of processes allowed on the system has exceeded. Yet another reason could be that there is not enough swap space.
Kernel Space
Parent Process
Child Process pid = 0
pid = 1234pid = 12345
pid = 0