3 ms·
Another time when writing a quick and dirty spinlock is reasonable is inside a logging library. A logging library would normally use a full-featured mutex, but
by kccqzy 9mo ago
Another time when writing a quick and dirty spinlock is reasonable is inside a logging library. A logging library would normally use a full-featured mutex, but what if we want the mutex implementation to be able to log? Say the mutex can log that it is non recursive yet the same thread is acquiring it twice; or that it has detected a deadlock. The solution is to introduce a special subset of the logging library to use a spinlock.
- wizzwizz4 9mo agoI'm not sure how a spinlock solves this problem. Wouldn't that just cause the process to hang busy?
- direwolf20 9mo agoOnly until the other thread leaves the logger
- wizzwizz4 9mo agoOh, I see: the spinlock is for logging the deadlocks of other mutices, not for magically remediating deadlocks.