mcs – 041 block 1 unit 3 interprocess communication and synchronization

Upload: dhabaliakirit

Post on 05-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    1/10

    MCS 041

    Block 1 Unit 3Interprocess Communication And Synchronization

    By

    Kirit A. Dhabalia

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    2/10

    Content

    Interprocess Communication

    Interprocess Synchronization

    Semaphores Locks

    Monitors and Condition Variables

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    3/10

    Interprocess Communication

    Supported by OS, allow one process to communicate with anotherprocess. Could be on same computer or different computerconnected through a network

    It is not generally supported by single process operating systemssuch 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 theaccess, provided printer is not being used by another processotherwise 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 theresource at the same time (Ex. Printer)

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    4/10

    Interprocess Communication

    Shared-Memory System

    Message-Passing System

    Direct

    Indirect

    Capacity Link

    Zero Capacity

    Bounded Capacity

    Unbounded Capacity

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    5/10

    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

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    6/10

    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

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    7/10

    Locks

    Locks are another synchronization mechanism

    These locks has got two operation

    Acquire

    Release

    A process will acquire a lock before accessinga shared variable and later it will be released

    The difference between a lock and asemaphore is that a lock is released only bythe process that have acquired if earlier

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    8/10

    Monitors And Condition Variables

    While using semaphores and locks, one must bevery careful, because a simple spelling mistakemay lead that the system ends up in a deadlock

    Monitors are written to make synchronizationeasier and correctly.

    Monitors are some procedures, variables anddata structures grouped together in a package

    If a process cannot enter the monitor it mustblock itself. This operation is provided by thecondition variables

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    9/10

  • 7/31/2019 MCS 041 Block 1 Unit 3 Interprocess Communication and Synchronization

    10/10

    Thank You