3 ms·
”Quickly dropping a very important lock and retaking it is a common anti-pattern I've observed across the XNU codebase […] This is trying to detect whether an
by Someone 8y ago
”Quickly dropping a very important lock and retaking it is a common anti-pattern I've observed across the XNU codebase
[…]
This is trying to detect whether another thread acquired and dropped the lock while this thread dropped it then reacquired it. If so, the code checks whether there's still a vm_map_entry covering the current address its trying to copy and then bails out and looks up the entry again.”
I find that disconcerting. Apparently, the writers of this didn’t have a clear model of what locks are needed where, or (worse) they had a model, but knew it didn’t work.
Anybody writing that code should have seen this coming.
- londons_explore 8y agoAny sufficiently complex software will at some point require dropping and reacquiring a lock. The trick is you have to assume everything changed under you when you dropped the lock, and recheck everything