-#ifndef HEADER_SYNCH_H
-#define HEADER_SYNCH_H 1
+#ifndef THREADS_SYNCH_H
+#define THREADS_SYNCH_H
#include <list.h>
#include <stdbool.h>
struct list waiters; /* List of waiting threads. */
};
-void sema_init (struct semaphore *, unsigned value, const char *);
+void sema_init (struct semaphore *, unsigned value, const char *name);
void sema_down (struct semaphore *);
void sema_up (struct semaphore *);
const char *sema_name (const struct semaphore *);
/* Lock. */
struct lock
{
- char name[16]; /* Name (for debugging purposes only). */
struct thread *holder; /* Thread holding lock (for debugging). */
struct semaphore semaphore; /* Binary semaphore controlling access. */
};
-void lock_init (struct lock *, const char *);
+void lock_init (struct lock *, const char *name);
void lock_acquire (struct lock *);
void lock_release (struct lock *);
bool lock_held_by_current_thread (const struct lock *);
struct list waiters; /* List of waiting threads. */
};
-void cond_init (struct condition *, const char *);
+void cond_init (struct condition *, const char *name);
void cond_wait (struct condition *, struct lock *);
void cond_signal (struct condition *, struct lock *);
void cond_broadcast (struct condition *, struct lock *);
const char *cond_name (const struct condition *);
-#endif /* synch.h */
+#endif /* threads/synch.h */