Conceptual
Login

Proving a Field Is Guarded by Another Lock

Sometimes one lock protects data that lives somewhere else: a list held in a parent structure guards fields inside each of its children. Putting the data inside the lock is then impossible, so the kernel crate offers a wrapper that names the lock that protects it and will only hand out access when you present that lock's guard. The rule that used to be a comment saying must hold the parent lock becomes something the compiler checks. It is how you keep the data-inside-the-lock guarantee when the structure of your driver will not allow literal nesting.

Questions this Concept answers

  • Why can data guarded by a parent object's lock not simply be stored inside that lock?