projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Minor doc improvements.
[pintos-anon]
/
src
/
threads
/
synch.h
diff --git
a/src/threads/synch.h
b/src/threads/synch.h
index c8ac2f446508a793962d455e6d3551e1af56d125..6b8f550e8798f6b9b916cf15ce8ec72861e283a8 100644
(file)
--- a/
src/threads/synch.h
+++ b/
src/threads/synch.h
@@
-1,5
+1,5
@@
-#ifndef
HEADER
_SYNCH_H
-#define
HEADER_SYNCH_H 1
+#ifndef
THREADS
_SYNCH_H
+#define
THREADS_SYNCH_H
#include <list.h>
#include <stdbool.h>
#include <list.h>
#include <stdbool.h>
@@
-7,42
+7,44
@@
/* A counting semaphore. */
struct semaphore
{
/* A counting semaphore. */
struct semaphore
{
- char name[16]; /* Name (for debugging purposes only). */
unsigned value; /* Current value. */
struct list waiters; /* List of waiting threads. */
};
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);
void sema_down (struct semaphore *);
void sema_down (struct semaphore *);
+bool sema_try_down (struct semaphore *);
void sema_up (struct semaphore *);
void sema_up (struct semaphore *);
-const char *sema_name (const struct semaphore *);
void sema_self_test (void);
/* Lock. */
struct lock
{
void sema_self_test (void);
/* 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. */
};
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 *);
void lock_acquire (struct lock *);
void lock_acquire (struct lock *);
+bool lock_try_acquire (struct lock *);
void lock_release (struct lock *);
bool lock_held_by_current_thread (const struct lock *);
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
{
/* Condition variable. */
struct condition
{
- char name[16]; /* Name (for debugging purposes only). */
struct list waiters; /* List of waiting threads. */
};
struct list waiters; /* List of waiting threads. */
};
-void cond_init (struct condition *
, const char *
);
+void cond_init (struct condition *);
void cond_wait (struct condition *, struct lock *);
void cond_signal (struct condition *, struct lock *);
void cond_broadcast (struct condition *, struct lock *);
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 */
+/* Optimization barrier.
+
+ The compiler will not reorder operations across an
+ optimization barrier. */
+#define barrier() asm volatile ("")
+
+#endif /* threads/synch.h */