21
L Cdr Manish Tandon, CAT CONCURRENT PROCESS

Concurrent process

Embed Size (px)

Citation preview

Page 1: Concurrent process

L Cdr Manish Tandon, CAT

CONCURRENT PROCESS

Page 2: Concurrent process

L Cdr Manish Tandon, CAT

CONCURRENT PROCESS

What are the consequences and ramification of the co-existence of processes within one system?

What are the effects of processes competing for resources?

How are the need of processes which want to communicate with each other met?

Page 3: Concurrent process

L Cdr Manish Tandon, CAT

TYPES OF PROCESS

Fully independent processes; Users working on applications within the system such as compiling and running their own programmes.

Independent but related processes;Users contributing to one application such as several clerks in an order processing department.

Page 4: Concurrent process

L Cdr Manish Tandon, CAT

TYPES OF PROCESS

Concurrent Programming applications, Applications constituted as a set of co-operating processes.

Page 5: Concurrent process

L Cdr Manish Tandon, CAT

RESOURCES

Obvious Resources: Processor, Main Memory, I/O devices, Secondary Storage, etc.

Logical Resources: Data Items in Main Memory or on secondary storage employed for system such as message queues, shared data structures etc.

Page 6: Concurrent process

L Cdr Manish Tandon, CAT

RESOURCES

Resources can be classified as reusable or consumable.

Reusable resource is not destroyed by being used , eg.. Physical Resource – Processor, etc. if resource can be used by one process at a time it is called serially reusable , eg. Printer.

Page 7: Concurrent process

L Cdr Manish Tandon, CAT

RESOURCES

Consumable Resource is a transient data item, a signal which is created by one process and ceases to exist when received by another.

Page 8: Concurrent process

L Cdr Manish Tandon, CAT

MUTUAL EXCLUSION & DEADLOCK

Principal problem arising from sharing of serially reusable resources is to ensure that they are only used by one process at one time ie… ensure mutual exclusion. Eg. A printer must remain allocated to the process until the printout is completed.

Page 9: Concurrent process

L Cdr Manish Tandon, CAT

MUTUAL EXCLUSION & DEADLOCK

Mutual Exclusion creates the potential danger of Deadlock.

A process is said to be deadlocked if it is waiting for a resource held by the other.

Page 10: Concurrent process

L Cdr Manish Tandon, CAT

ACHIVING MUTUAL EXCLUSIONOperating System maintains the centralised control of resources , hence Mutual Exclusion is readily achieved.

Software Solutions – Flags, etc.

Hardware Solutions - Machine Instructions (Test And Set), etc.

Semaphores – Development of Software Solution, Low Level software techniques such as GOTO, etc.

Page 11: Concurrent process

L Cdr Manish Tandon, CAT

ACHIVING MUTUAL EXCLUSION

Monitor – programming constructs used to control access to shared data.

File and Record Locking.

Page 12: Concurrent process

L Cdr Manish Tandon, CAT

DEADLOCK

Deadlock can arise in many different and unanticipated situations. They generally occur in normal running of a system and can not be attributed to faulty programming only.

Page 13: Concurrent process

L Cdr Manish Tandon, CAT

CONDITIONS FOR DEADLOCKMutual Exclusion : Only one process can use a resource at a time.

Resource Holding : Processes hold some resources while requesting more.

No Preemption : Resources can not be forcibly removed from a process.

Circular Wait : A closed circle of processes exists, where each process requires a resource held by next.

Page 14: Concurrent process

L Cdr Manish Tandon, CAT

DEALING WITH DEADLOCKDeadlock Prevention : Deadlock not occur due to adoption of sound resource allocation policy. Eliminates all four conditions and does not let them occur. Inefficient way of handling deadlock.

Page 15: Concurrent process

L Cdr Manish Tandon, CAT

DEALING WITH DEADLOCKDeadlock Avoidance : Although deadlock is still possible, the system will avoid it when one threatens, ie.. when a deadlock would arise from a particular resource allocation - this allocation is not done. Various techniques used – Bankers Algorithm, etc.

Page 16: Concurrent process

L Cdr Manish Tandon, CAT

DEALING WITH DEADLOCKDeadlock Detection : A deadlock detection strategy accepts the risk of a deadlock occurring and periodically executes a procedure to detect any in place. The usual principle applied is to detect circular wait situation in resource allocation and request information maintained by the system… while this is quite feasible , it can consume considerable processing time. The frequency of checking routine would need to reflect the probability of deadlock occurrence.

Page 17: Concurrent process

L Cdr Manish Tandon, CAT

INTERPROCESS COMMUNICATIONModern Operating System provide variety of facilities to processes which require to them communicate with on another. The nature of communication ranges from the simple signaling of an event, to the passing of messages via a queuing system . Techniques available for these include :

Signals Shared Files ie.. Pipes Message Passing Shared Memory

Page 18: Concurrent process

L Cdr Manish Tandon, CAT

INTERPROCESS COMMUNICATIONSignals : A fairly primitive form of communication used to alert a process to occurrence of some event usually abnormal condition something similar to Interrupt. Eg. Ctrl ‘C’ Key Combination, Kernel sends signal SIGINT to all processes which would terminate by default due to receipt of this signal except SHELL which ignores it.

Page 19: Concurrent process

L Cdr Manish Tandon, CAT

INTERPROCESS COMMUNICATIONPipes : Pipe is a mechanism whereby the output of one process is directed into the input of another. Implicit in this operation is the creation of an temporary intermediate file into which the first process writes its output and from which the second process reads its input. Widely used in UNIX.

Page 20: Concurrent process

L Cdr Manish Tandon, CAT

INTERPROCESS COMMUNICATIONMessage Passing : A sequence of arbitrary characters can be sent from one process to other. Similar to Pipe, but Message Passing is more flexible and transparent. Communication takes place via message queues.

Page 21: Concurrent process

L Cdr Manish Tandon, CAT

INTERPROCESS COMMUNICATIONShared Memory : Concept of shared memory segments , which can be shared by two or more processes. Unix provides this facility, by providing four specific system calls for this technique.