Owner Lock

C++ provides a multiple-acquisition lock (owner lock).

The type uOwnerLock defines an owner lock:

  • An owner lock is owned by the task that acquires it; all other tasks attempting to acquire the lock block until the owner releases it.
  • The owner of an owner lock can acquire the lock multiple times
    • but a matching number of releases must occur or the lock remains in the owner’s possession and other tasks cannot acquire it.
  • times() returns the number of times the lock has been acquired by the lock owner
  • owner() returns the task owning the lock or NULL if there is no owner
  • acquire() acquires the lock if it is open, otherwise the calling task blocks until it can acquire the lock
    • i.e., it does not block; the value true is returned if the lock is acquired and false otherwise.
  • release() releases the lock and if there are waiting tasks, one is restarted; waiting tasks are released in FIFO order.

If the mutex lock is an owner lock, a lock owner may enter the critical section multiple times.