More Locks Flashcards
1
Q
We know that “Spin Locks” are not optimal because precious CPU time gets used by spinning. The solution to that is a system call provided by the OS called “yield”.
- What does it do?
- What is the problem with “yield”?
A
- Instead of “spin waiting” we use yield() to give the CPU time to another process.
There are two problems:
1. Scalability: With 100 threads maybe 99 need to yield.
2. Fairness: Some threads can yield to death (starve)
2
Q
Explain the usage of a condition variable.
A
(Use the spick for help)