6. Mutual exclusion
• Mutex is a object on which thread can acquire
lock
Mutex Flavours:
1) Scalable
2)Fair
3)Recursive
4)Yield or Block
Mutex Behaviours:
1) spin_mutex
2) queuing_mutex
3) spin_rw_mutex and
queuing_rw_mutex
4) speculative_spin_mutex,
speculative_spin_rw_mutex
5) mutex and recursive_mutex
6) null_mutex and
null_rw_mutex
7.
8. Atomic operations
• Class atomic<T> : implementation in c++ style
• Usage: For thread safe reference counting
• 5 Fundamental operation
1. =x
2. x=
3. X.fetch_and_store(y)
4. x.fetch_and_add(y)
5. x.compare_and_swap(y,z)
9. Concurrent container
• Container by Intel TBB offers high level of
concurrency by
1. Fine-grained locking
2. Lock-free technique
• concurrent_queue
• concurrent_hash_map
• concurrent_vector
10. Task scheduler
Over subscription
Fair scheduling
High overload
Load imbalance
Scalability
One TBB thread per hardware thread
Non pre emptive unfair scheduling
Programmer specific task, not thread
Work stealing balance load
Specify task, how to create them, not threads