49#define barrier() asm volatile ("" : : : "memory")
struct list waiters
List of waiting threads.
struct thread * holder
Thread holding lock (for debugging).
unsigned value
Current value.
struct list waiters
List of waiting threads.
A kernel thread or user process.
bool lock_held_by_current_thread(const struct lock *)
Returns true if the current thread holds LOCK, false otherwise.
void lock_release(struct lock *)
Releases LOCK, which must be owned by the current thread.
void cond_wait(struct condition *, struct lock *)
Atomically releases LOCK and waits for COND to be signaled by some other piece of code.
void sema_up(struct semaphore *)
Up or "V" operation on a semaphore.
void cond_init(struct condition *)
Initializes condition variable COND.
void sema_down(struct semaphore *)
Down or "P" operation on a semaphore.
bool sema_try_down(struct semaphore *)
Down or "P" operation on a semaphore, but only if the semaphore is not already 0.
void lock_acquire(struct lock *)
Acquires LOCK, sleeping until it becomes available if necessary.
void sema_init(struct semaphore *, unsigned value)
This file is derived from source code for the Nachos instructional operating system.
void cond_signal(struct condition *, struct lock *)
void sema_self_test(void)
Self-test for semaphores that makes control "ping-pong" between a pair of threads.
void cond_broadcast(struct condition *, struct lock *)
Wakes up all threads, if any, waiting on COND (protected by LOCK).
bool lock_try_acquire(struct lock *)
Tries to acquires LOCK and returns true if successful or false on failure.
void lock_init(struct lock *)
Initializes LOCK.