Better HN
topnewbestaskshowjobs
Log inSign up

davekilian

65 karma · joined Nov 23, 2022 (4y ago) · 4 submissions

Submissions

comment 2y ago · link · parent

This one? https://evaparish.com/blog/how-i-edit

comment 2y ago · link · parent

I was wondering how something so basic could go unnoticed for so long. Halfway down the page on OP's link, a user u/rbmm provides a compelling answer: that there are (possibly expected?) cases where a thread trying to acquire the lock in shared mode can accidentally get it in exclusive mode instead. This is due to interleaving of atomic bit test-and-[re]set operations between the (shared mode acquire) thread and the (exclusive mode release) thread running simultaneously.

The repro code holds the shared lock while waiting for all other threads to acquire the shared lock, and thus deadlocks if any of the worker threads accidentally gets an exclusive lock. In "normal" use cases where the lock is used to protect some shared resource, threads holding the lock don't wait for each other, so there is no deadlock.

Interesting stuff!

3.

Making Sense of Acquire-Release Semantics(davekilian.com ↗)

2 points · by davekilian · 3y ago · discuss

4.

Guide to Lock Convoys(davekilian.com ↗)

62 points · by davekilian · 4y ago · 14 comments