Concurrency Control & Coordination
Synchronization Mechanisms
Mutual Exclusion
- Exclusive access to only one thread at at time
- mutex
Waiting on other threads
- Specific condition before proceeding
- Condition variable
Thread Creation
Thread type
- Thread data structure
- thread ID, PC, Stack Pointer, registers, stack, other attributes
Fork(procedure, args)
- create a thread
- not UNIX system fork
Join(thread)
- terminate a thread
Thread thread1;
Shared_list list;
thread1 = fork(safe_insert, 4);
safe_insert(6);
join(thread1); // wait until t1 completes