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 *);
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 char name[16]; /* Name (for debugging purposes only). */
25 struct thread *holder; /* Thread holding lock (for debugging). */
26 struct semaphore semaphore; /* Binary semaphore controlling access. */
29 void lock_init (struct lock *, const char *);
30 void lock_acquire (struct lock *);
31 void lock_release (struct lock *);
32 bool lock_held_by_current_thread (const struct lock *);
33 const char *lock_name (const struct lock *);
35 /* Condition variable. */
38 char name[16]; /* Name (for debugging purposes only). */
39 struct list waiters; /* List of waiting threads. */
42 void cond_init (struct condition *, const char *);
43 void cond_wait (struct condition *, struct lock *);
44 void cond_signal (struct condition *, struct lock *);
45 void cond_broadcast (struct condition *, struct lock *);
46 const char *cond_name (const struct condition *);
48 #endif /* threads/synch.h */