Process creation and termination In Operating System

farhanaslam127 9,825 views 36 slides May 17, 2015
Slide 1
Slide 1 of 36
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36

About This Presentation

In this Presentaion You will learn about Process Creation and Termination In Linux


Slide Content

Process creation and termination Agenda of Lecture Why and how process are created Resource Sharing Execution Address Space System Calls

Process Creation Tree Hierarchy Question : When a child Process is created , whether the child process will share info with their parent process and how its execution might be?

Resource Sharing They may settle three arrangements Parent and children share all resources Child and parent share subset of resources They may share no resources

Execution Parent has created a child Process how their execution will go on Parent stops waiting for child to finish itself Either they perform simultaneously Either parents end and child continues

Unix & Linux Unix / Linux Parent and child Process Question: If they both look the same and usually if both the process of the same are running what will be the need of it to run?

Unix & Linux ( Parent –Child) System calls: Fork() To create a child Process Exit() To terminate a child Process Wait() Parent Process wait for a child Process Exec() Process overwrites itself with another executable program

Process Tree in Unix

Process Termination Reasons: The allocated resources to the child has been exceeded Parent Process has created lots of child Process Child Process was created for a purpose whose task is completed

System Calls …… Fork() When the fork system call is executed a new process is created which consist of copy of the parent process The mechanism allows parent process to communicate easily with the child Synopsis: #include <sys/ types.h > #include< unistd.h > Pid _ t fork(void)

Wait() A process created a child process , process calls wait(), until a child process is terminated the parent process will remain in waiting state. Synopsis for wait system call # include <sys/ types.h > #include <sys/ wait.h > pid_t wait( int * stat_loc );

Exec() A process that calls EXEC() it will overwrite itself with another executable There is no return value Synopsis of execlp () is given as #include < unistd.h > int execlp ( const char *file, const,char *arg0, ..., const char * argn ,(char *)Null);

Sample Code

Cooperating Processes Advantages of Cooperating Process Information Sharing Computation speedup Modularity

Producer Consumer Problem Over view of the Problem We may have processes which produce something, we place them some where (file/main memory) and then there are processes who will consume these things . The place where these items are placed can be bounded on unbounded

Bounded Buffer consumer problem We call space a buffer which is bounded. Process that creates an item place it in an array slot called producer process Process that consume the created item is called consumer problem

Buffer Buffer can be filled and empty . If producer produce item at faster rate then consumer consumption then it may get full. In this case if the producer another item then it will have to wait If the buffer is empty then the consumer is consuming at faster rate then producing so then the consumer will have to wait.

General Problem Description We have fixed size buffer ,two processes( Producer and Consumer ) .Producer produce the item. P lace it in the right full place in the buffer updates the index variable for the next item to place. Similarly index maintain the index variable which points to the next item to be consumed.

Semantics of the problem

Solution of the Problem

Inter Process Communication The agenda is based on parent and child process communication. Channels required for communication Properties of channels for different communication System calls ( Read and write )

Operation for IPC Operation Send A process will send something to another process Operation Receive A process will receive something form the sender process Message that is sent may be unlimited or bounded in terms of bytes

Communication means Direct Communication Indirect Communication

Communication Channels Provide medium of communication Both communication means employ medium of communication Few question to understand……… How the channels are establish? How we may link two processes How many channels a cooperating process have? What is the capacity of the channels? Is the link is bidirectional or unidirectional?

Direct Communication In direct Communication links are establish automatically Between each pair there would be one link Link may be unidirectional or bidirectional Name of the process Message

Indirect Communication Sender or receiver doesn’t name to sender process or receiver process and vice versa Example Mail Box It is only possible if the process share the same mail box ( Channel)

Issues with indirect communication We have three processes P1, P2 and P3.P1 sends a message and P2,P3 are the receiver. Which Process will receive the message?

Solutions

Process Synchronization

Channels capacity