Horus Lock Interface

This document is part of the online Horus Documentation, under Horus Utilities.


Locks allow the implementation of critical regions. They may only be used in a very disciplined way. Locks must be acquired and released in a purely nested fashion, and only by the same thread. Thus after locking A and B, B and A should be unlocked in reverse order. Unlike semaphores, you can release a lock only once, and only after it has been acquired. Some implementations take advantage of the locking discipline and provide a particularly efficient implementation of locks, for example by implementing them as monitors.

SOURCES

machdep/*/thread.c

INCLUDE

#include "muts.h"

INTERFACE

void l_init(
	char *name,
	lock_t *lock
);
Initialize a lock to an unlocked state. Locks, like semaphores, have names, which are primarily used for debugging purposes.
void l_lock(
	lock_t *lock
);
Acquire the lock. Blocks if the lock is held by a different thread.
void l_unlock(
	lock_t *lock
);
Release the lock. If another thread is blocked trying to acquire the lock, resume that thread. If there are more than one blocked, resume only one.
void l_rel(
	lock_t *lock
);
Release resources associated with this lock.

EXAMPLE

not available yet


This document is part of the online Horus Documentation, under Horus Utilities.