April 2012
Intermediate to advanced
352 pages
8h
English
Here are some general guidelines for lock usage. Note that these aren’t hard-and-fast rules, just things to keep in mind.
When an exclusive hold or lock is acquired, the holder usually assumes that it has exclusive access to the objects the lock protects. Unfortunately, recursive locks can break this assumption in some cases. As an example, suppose function F1 uses a recursive lock L to protect object O. If function F2 acquires L, modifies O, leaving it in an inconsistent state, and then calls F1, F1 will recursively acquire L and falsely assume that O is in a consistent state.[7]
One solution to this problem is to use a nonrecursive lock and to rewrite F1 so that it does not acquire L. Instead, ...
Read now
Unlock full access