1 / 21

ITFN 3601 Introduction to Operating Systems

ITFN 3601 Introduction to Operating Systems. Lecture 5 Inter-Process Communication. Agenda. IPC Basics Semaphores & Mutex Monitors & Barriers Message Passing IPC Problems Dining Philosophers Readers & Writers. IPC Basics. Race Conditions Critical Region One at a Time

africa
Download Presentation

ITFN 3601 Introduction to Operating Systems

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. ITFN 3601Introduction to Operating Systems Lecture 5 Inter-Process Communication

  2. Agenda • IPC Basics • Semaphores & Mutex • Monitors & Barriers • Message Passing • IPC Problems • Dining Philosophers • Readers & Writers

  3. IPC Basics • Race Conditions • Critical Region • One at a Time • Speed Independent • Non-Critical Regions Immaterial • Finite Waiting • Solution? • Mutual Exclusion

  4. Race Conditions • Race conditions generally involve one or more processes accessing a shared resource (such a file or variable), where this multiple access has not been properly controlled • Race conditions appear in three situations: • implicit calls to schedule from within a function • blocking operations • access to data shared by interrupt code and system calls

  5. Definition of Critical Sections • The overlapping portion of each process, where the shared variables are being accessed. Mutual Exclusion – if Pi is executing in one of its critical sections, noPj, i ≠ j, is executing in its critical sections

  6. Critical Regions • No two processes may be simultaneously inside their critical regions • No assumptions may be made about speeds or the number of CPUs • No process running outside its critical region may block another process • No process should have to wait forever to enter its critical region

  7. Mutual Exclusion • Busy Waiting or Spin Lock • Priority inversion • Producer-Consumer Problem

  8. Basic Mutual Exclusion • Disable Interrupts (BAD!) • Only works for one processor • User must remember to re-enable interrupts • Lock variable (GETTING CLOSER) • How do you lock the lock? • Lockstep Alternation (ALMOST) • Violates 3rd rule of critical regions

  9. Basic Mutual Exclusion (cont.) • “Interested” Flags • Test & Set • Atomic Action • Read Value to see locked • Automatically set to locked, just in case • Sleep & Wakeup

  10. Semaphores • Tracks number of Sleeps & Wakeups • Down & Up • Historically P & V – Dutch (Thanks, Dijkstra!) • Special Cases • Down from a 0 • Process or Thread Sleeps until a new Wakeup • Up from 0 • Random Sleeper for this Wakeup is Triggered

  11. Binary Semaphores • Mutex • Like a Standard Lock • Atomicity provides self-locking • Idle Wait • If locked, thread yields • Simpler Semaphores • Fundamental Mutual Exclusion Tool

  12. Monitors & Barriers • Monitors • Compiler based mutual exclusion • Condition Variables • Wait • Signal • Barriers • Forced resynchronization of processes

  13. Barriers

  14. Networked Critical Region? • How do you enforce Critical Regions across a network? • Message Passing • Each signal is explicitly given a destination • Authentication? • Acknowledgement of Receipt?

  15. IPC (Dining Philosophers) • Multiple processes attempting to obtain multiple resources • Not enough resources to satisfy all requests at all times (Wait necessary) • Why is this relevant?

  16. Philosophers Demonstration

  17. Philosopher Resolution? • Patterned locking? • Take left, then take right? • Locking the entire ‘find fork’ area? • Steal your forks while no one else can • State Array? • Track who has forks, who is waiting

  18. Philosopher Locked Table

  19. Readers & Writers • Multiple readers can co-exist • Two people can read the same page • Multiple writers cannot • Two people cannot write the same page, they will forever be getting in the way • Writers and readers cannot co-exist • Cannot read what is not written

  20. Readers & Writers (cont) • Reader on Reader • Allow it in • Reader on Writer • Writer on Writer • Must wait for Writer to finish • Writer on Reader • Must wait for Reader to finish

  21. Summary • Coordination between processes how? • Locking & Sleeping • TSL Command • Counting Wakeups • Monitors • Networked Coordination? • Message Passing • Barriers

More Related