1 / 9

Monitors and Inter-Process Communication

Monitors and Inter-Process Communication. Basic Concept. Consists of a lock and zero or more condition variables A queue. Monitors. Look like C++ "classes" encapsulation private mutex (semaphore) variable public interfaces public interfaces use P, V for protection

Download Presentation

Monitors and Inter-Process Communication

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Monitors and Inter-Process Communication

  2. Basic Concept • Consists of a lock and zero or more condition variables • A queue

  3. Monitors • Look like C++ "classes" • encapsulation • private mutex (semaphore) variable • public interfaces • public interfaces use P, V for protection • acts like a "critical section"

  4. Condition Variables (cv's) • Private to monitor • Access via: • wait() – suspends process • signal() – lets ONE process resume • queue() – TRUE if #waiters on cv > 0 • 2 approaches • Hoare – p1 waiting, p0 signals, p1 starts now • Mesa (Hansen) – p1 waiting, p0 signals and continues to run, p1 re-checks when p0 ends • fewer context switches

  5. Comparison • Hoare semantics if (R is held) R.wait(); //proceed • Mesa semantics while (R held) R.wait(); // forces re-try //proceed

  6. Mesa vs. Hoare • Mesa: signaler keeps lock, waking thread must wait on acquire • Hoare: signaler releases lock, waking thread acquires and runs

  7. IPC • Pipes • anonymous • limited to parent-child due to file reference • child inherits pipe-end as an open file • named • pipe is opened with a name • names are system-wide • managed like files • Message passing • send() & receive() • synchronous & asynchronous

  8. Notes on Java • The JVM • uses monitors for mutual exclusion • provides wait and notify for cooperation

  9. Condition Variables vs Semaphores

More Related