Only one variable is usually updated (shared) by the two threads.
Don't need variable to determine whether buffer is full; you can just use buf.head less buf.tail == N.
Race conditions result from bad interleaving of processes.\
Instead of locks, you could use scheduler.
Compare & Exchange
Optimistic Concurrency
Could you write an entire O/S without locks?
Most O/S make heavy use of doubly-linked lists.
Intel's product roadmap assumes transactional memory to aid developers in wirting code to take advantage of multiple processors.
Deadlock -- what do you do when none of the threads are making progress?
Graph deadlock as a directed cycle with inter-thread dependencies.
4 necessary conditions for deadlock:
- Limited Access
- No Preemption
- Multiple Independent Requests (hold & wait)
- Circularity in graph of requests
Circularity is the easiest condition to violate.
Two-Phase Locking -- simple deadlock control.
How have databases traditionally dealt with deadlocks?
No comments:
Post a Comment