4 ms·
busy-waiting is a valid technique for some use-cases (and gives better performance in those situations) than other techniques. Please research your topic.
by TickleSteve 8y ago
busy-waiting is a valid technique for some use-cases (and gives better performance in those situations) than other techniques.
Please research your topic.
- devxpy 8y agoYes, but isn't it more CPU intensive? (Speaking purely from experience. Don't have a fancy CS degree)
- TickleSteve 8y agoIt uses 100% CPU, true but when the duration of the lock is extremely small (i.e. nanoseconds->microseconds) the total CPU usage is less than arranging for an OS level context-switch. In other words, you use it when synchronising with hardware or when implementing test-and-set primitives for higher level mechanisms. Crucially, the time that the lock is held for must be very short. Given those restrictions and use cases you get a very efficient low latency locking mechanism.