4.9 Ordered Locking
The Ordered Locking Pattern is another way to ensure that deadlock cannot occur, this time by preventing condition 4 (circular waiting) from occurring. It does this by ordering the resources and requiring that they always be locked by a client in that specified order. If this is religiously enforced, then no circular waiting condition can ever occur.
4.9.1 Abstract
The Ordered Locking Pattern eliminates deadlock by ordering resources and enforcing a policy in which resources must be allocated only in a specific order. For monadic (that is, functions that can be used independently of others) operations, the client can invoke them without special consideration and the called function will lock and release the resource internally. ...
Get Design Patterns for Embedded Systems in C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.