X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fthreads%2Fsynch.h;h=d21ecff08ca546473cbfc7d84229fa5d54310fab;hb=3625c2e6aba3b282f91282492c4b3fba324816c1;hp=e64bc6da2abf4c7591d940f19be4fab14ab591df;hpb=8b509aacccb9bb7b75f08aa3889d53770027a497;p=pintos-anon diff --git a/src/threads/synch.h b/src/threads/synch.h index e64bc6d..d21ecff 100644 --- a/src/threads/synch.h +++ b/src/threads/synch.h @@ -4,11 +4,12 @@ #include #include "list.h" +/* A counting semaphore. */ struct semaphore { - char name[16]; - unsigned value; - struct list waiters; + char name[16]; /* Name (for debugging purposes only). */ + unsigned value; /* Current value. */ + struct list waiters; /* List of waiting threads. */ }; void sema_init (struct semaphore *, unsigned value, const char *); @@ -17,11 +18,12 @@ void sema_up (struct semaphore *); const char *sema_name (const struct semaphore *); void sema_self_test (void); +/* Lock. */ struct lock { - char name[16]; - struct thread *holder; - struct semaphore semaphore; + 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 *); @@ -30,10 +32,11 @@ void lock_release (struct lock *); bool lock_held_by_current_thread (const struct lock *); const char *lock_name (const struct lock *); +/* Condition variable. */ struct condition { - char name[16]; - struct list waiters; + char name[16]; /* Name (for debugging purposes only). */ + struct list waiters; /* List of waiting threads. */ }; void cond_init (struct condition *, const char *);