1 #ifndef THREADS_SYNCH_H
2 #define THREADS_SYNCH_H
7 /* A counting semaphore. */
10 char name[16]; /* Name (for debugging purposes only). */
11 unsigned value; /* Current value. */
12 struct list waiters; /* List of waiting threads. */
15 void sema_init (struct semaphore *, unsigned value, const char *name);
16 void sema_down (struct semaphore *);
17 void sema_up (struct semaphore *);
18 const char *sema_name (const struct semaphore *);
19 void sema_self_test (void);
24 struct thread *holder; /* Thread holding lock (for debugging). */
25 struct semaphore semaphore; /* Binary semaphore controlling access. */
28 void lock_init (struct lock *, const char *name);
29 void lock_acquire (struct lock *);
30 void lock_release (struct lock *);
31 bool lock_held_by_current_thread (const struct lock *);
32 const char *lock_name (const struct lock *);
34 /* Condition variable. */
37 char name[16]; /* Name (for debugging purposes only). */
38 struct list waiters; /* List of waiting threads. */
41 void cond_init (struct condition *, const char *name);
42 void cond_wait (struct condition *, struct lock *);
43 void cond_signal (struct condition *, struct lock *);
44 void cond_broadcast (struct condition *, struct lock *);
45 const char *cond_name (const struct condition *);
47 #endif /* threads/synch.h */