previous up next
Go backward to Memory Access
Go up to Top
Go forward to Synchronization Mechanisms
RISC-Linz logo

Shared Memory Synchronization

Problem: need mutual exclusion on shared data structures

int stack[];
int sptr = 0;
P: loop                
     v = produce()          
     stack[sptr] = v  | C1
     sptr++           |     
C: loop
     sptr--           | C2
     v = stack[sptr]  |
     consume(v)

Author: Wolfgang Schreiner
Last Modification: October 27, 1997

previous up next