projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
%zd -> %zu
[pintos-anon]
/
src
/
threads
/
synch.h
diff --git
a/src/threads/synch.h
b/src/threads/synch.h
index e64bc6da2abf4c7591d940f19be4fab14ab591df..ad8423891bad260215a77d0274dddfd75c960962 100644
(file)
--- a/
src/threads/synch.h
+++ b/
src/threads/synch.h
@@
-1,14
+1,15
@@
-#ifndef
HEADER
_SYNCH_H
-#define
HEADER_SYNCH_H 1
+#ifndef
THREADS
_SYNCH_H
+#define
THREADS_SYNCH_H
+#include <list.h>
#include <stdbool.h>
#include <stdbool.h>
-#include "list.h"
+/* A counting semaphore. */
struct 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 *);
};
void sema_init (struct semaphore *, unsigned value, const char *);
@@
-17,11
+18,11
@@
void sema_up (struct semaphore *);
const char *sema_name (const struct semaphore *);
void sema_self_test (void);
const char *sema_name (const struct semaphore *);
void sema_self_test (void);
+/* Lock. */
struct lock
{
struct lock
{
- char name[16];
- struct thread *holder;
- struct semaphore semaphore;
+ 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 *);
@@
-30,10
+31,11
@@
void lock_release (struct lock *);
bool lock_held_by_current_thread (const struct lock *);
const char *lock_name (const struct lock *);
bool lock_held_by_current_thread (const struct lock *);
const char *lock_name (const struct lock *);
+/* Condition variable. */
struct condition
{
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 *);
};
void cond_init (struct condition *, const char *);
@@
-42,4
+44,4
@@
void cond_signal (struct condition *, struct lock *);
void cond_broadcast (struct condition *, struct lock *);
const char *cond_name (const struct condition *);
void cond_broadcast (struct condition *, struct lock *);
const char *cond_name (const struct condition *);
-#endif /* synch.h */
+#endif /*
threads/
synch.h */