Interprocess Communication
Interprocess Communication
• mutual exclusion
if one process is using a shared variable or file
Disabling Interrupts.
Lock
• Currently 0.
Strict Alteration
• One process much slower
process 0 quickly complete the loop.
• Violation condition
Process 0 blocked by a process not in critical region.
Peterson’s Solution
• both processes call enter-region
• process 1 stores last - turn is 1
TSL Instruction
• LOCK:XCHG
Setting & Clearing Locks using TSL
Busy Waiting
• Process in a loop.
• L in critical region.
• H loops forever.
Procedure – Consumer Problem
Fatal Race Condition
Fatal Race Condition
• count read as 0.
Terms Related to Concurrency
Semaphore
• A semaphore 0 - no wakeups
Semaphore Operations
1. Initialized to 0 or 1
1.Mutual Exclusion
●
only one process at a time will be reading or writing the
buffer and the associated variables
2. Synchronization
●
certain event sequences do or do not occur
●
Producer stops running when the buffer is full
●
Consumer stops running when it is empty.
Solution for Infinite Buffer
Finite Circle Buffer
Solution Bounded Buffer