1 / 14

CSI 400/500 Operating Systems Spring 2009

CSI 400/500 Operating Systems Spring 2009. Lecture #16 – Synchronization with Monitors Wednesday, April 1 st. Multiple Synchronization. In modern operating systems, processes may share a set of resources. Each resource requires a semaphore Overhead gets overwhelming. AND Synchronization.

ccoogan
Download Presentation

CSI 400/500 Operating Systems Spring 2009

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. CSI 400/500 Operating Systems Spring 2009 Lecture #16 – Synchronization with Monitors Wednesday, April 1st

  2. Multiple Synchronization • In modern operating systems, processes may share a set of resources. • Each resource requires a semaphore • Overhead gets overwhelming

  3. AND Synchronization • Early attempts used a Wait function with multiple parameters • Obtained all resources at once • Required 2nd process to enqueue all resources

  4. Event • Discrete operating system entity • Has unique id and descriptor like thread • Performs operating system activities • Accessed via function calls

  5. Synchronization Event • Used for multiple resource synchronization • 3 functions: • Wait() • Signal() • Queue()

  6. Monitors • Self-contained multiple resource synchronization event • Object containing storage, procedures, interface, and queues • Only one process can “enter” monitor at a time • Can access any data or function in monitor

  7. Condition Variables • A variable on a crucial data area • Allows a process or thread to relinquish the monitor if it requires a resource elsewhere • Conditional variable has a queue

  8. Sample Monitor Dataarea Library of functions Conditional variable queues

  9. Interprocess Communication • Used by monitors to communicate among threads on their conditional variable queues • Necessary if data changes

  10. IPC types • Pipes • Traditional UNIX method • FIFO buffer at kernel level • Write() and read() • Message Passing • Used by most OS and used by monitors • Monitor contains mailbox • Send() and receive()

  11. Example #1 – Traffic signals • Think of one-lane crossing • Only allows one direction flow • Light changes if all cars pass or a timer goes off • Lights are traffic controlled, so cars don’t wait if no traffic in other direction

  12. Monitor – Example #1 • Enter monitor – one arrival() for each direction • Depart(direction) • Internal function switch() • Data is count of cars in each direction, RED/GREEN signals in each direction, and timer • Code seen on p 350

  13. Example #2 – Dining Philosophers • 5 place settings, bowl of spaghetti in middle • One fork per place setting • Philosopher requires two forks to eat

  14. Monitor – Example #2 • Each philosopher has state: thinking, hungry, eating • Counter of forks in action • PickupFork(p) – Philosopher p picks up fork • If 1st, sets state to hungry • If 2nd, sets state to eating • Finish(p) – releases fork and sets state to thinking • Code on pg 351

More Related