OS should be able to create and delete processes dynamically.
A. PROCESS CREATION
- When the OS or a user process decides to create a new process, it can proceed as follows:
- Assign a new process identifier and add its entry to the primary process table.
- Allocate space for the process (program+data) and user stack. The amount of space required can set to default values depending on the process type. If a user process spawns a new process, the parent process can pass these values to the OS.
- Create process control block.
- Set appropriate linkage to a queue (ready) is set.
- Create other necessary data structures (e.g. to store accounting information). - Parent process creates children processes, which, in turn create other processes, forming a tree of processes.
- Resource sharing possibilities
- Parent and children share all resources.
- Children share subset of parent’s resources.
- Parent and child share no resources. - Execution possibilities
- Parent and children execute concurrently.
- Parent waits until children terminate.
- Address space possibilities
- Child duplicate of parent.
- Child has a program loaded into it.
B. PROCESS TERMINATION
- A process terminates when it executes last statement and asks the operating system to delete it by using exit system call. At that time, the child process
- Output data from child to parent (via wait).
- Process’ resources are deallocated by operating system. - Parent may terminate execution of children processes via appropriate system called (e.g. abort). A parent may terminate the execution of one of its children for the following reasons:
- Child has exceeded allocated resources.
- Task assigned to child is no longer required.
- Parent is exiting. - Operating system does not allow child to continue if its parent terminates.
- Cascading termination.
0 comments:
Post a Comment