Você está na página 1de 10

MCS 041 Block 1 Unit 3

Interprocess Communication And Synchronization

By Kirit A. Dhabalia

Content
Interprocess Communication Interprocess Synchronization Semaphores Locks Monitors and Condition Variables

Interprocess Communication
Supported by OS, allow one process to communicate with another process. Could be on same computer or different computer connected through a network It is not generally supported by single process operating systems such as DOS. OS/2 and MS windows support an IPC mechanism called Dynamic Data Exchange If process needs to print its result, it must request the OS gives access to the printers device driver. OS must decide to grant the access, provided printer is not being used by another process otherwise process will be waiting until availability. Critical resource: It is a resource shared with constraints on its use (memory, files, printer ) Critical Section : It is code that accesses a critical resource Mutual Exclusion : both processes do not attempt to use the resource at the same time (Ex. Printer)

Interprocess Communication
Shared-Memory System Message-Passing System
Direct Indirect
Capacity Link
Zero Capacity Bounded Capacity Unbounded Capacity

Interprocess Synchronization
Serialization Mutexes: Mutual Exclusion Critical Sections: The Mutex Solution Bakerys Algorithm

Semaphores Classical Problems In Concurrent Programming


Producers/Consumers Problems
With a unbounded buffer With a bounded buffer

Readers and Writers Problem Dining Philosophers Problem Sleeping Barber Problem

Classical Problems In Concurrent Programming


Producers/Consumers Problem
With an unbounded buffer With a bounded buffer

Readers and Writers Problem Dining Philosophers Problem Sleeping Barber Problem

Locks
Locks are another synchronization mechanism These locks has got two operation
Acquire Release

A process will acquire a lock before accessing a shared variable and later it will be released The difference between a lock and a semaphore is that a lock is released only by the process that have acquired if earlier

Monitors And Condition Variables


While using semaphores and locks, one must be very careful, because a simple spelling mistake may lead that the system ends up in a deadlock Monitors are written to make synchronization easier and correctly. Monitors are some procedures, variables and data structures grouped together in a package If a process cannot enter the monitor it must block itself. This operation is provided by the condition variables

Thank You

Você também pode gostar