projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change bitmap interface, update references.
[pintos-anon]
/
src
/
threads
/
synch.c
diff --git
a/src/threads/synch.c
b/src/threads/synch.c
index d7601dacddc89f7c772d3340cf0e856b81c82f09..85af57d63ac8c0f59f8b254c0d4db46f495d392b 100644
(file)
--- a/
src/threads/synch.c
+++ b/
src/threads/synch.c
@@
-26,10
+26,11
@@
MODIFICATIONS.
*/
MODIFICATIONS.
*/
-#include "synch.h"
-#include "interrupt.h"
-#include "lib.h"
-#include "thread.h"
+#include "threads/synch.h"
+#include <stdio.h>
+#include <string.h>
+#include "threads/interrupt.h"
+#include "threads/thread.h"
/* Initializes semaphore SEMA to VALUE and names it NAME (for
debugging purposes only). A semaphore is a nonnegative
/* Initializes semaphore SEMA to VALUE and names it NAME (for
debugging purposes only). A semaphore is a nonnegative
@@
-105,25
+106,24
@@
sema_name (const struct semaphore *sema)
static void sema_test_helper (void *sema_);
/* Self-test for semaphores that makes control "ping-pong"
static void sema_test_helper (void *sema_);
/* Self-test for semaphores that makes control "ping-pong"
- between a pair of threads. Insert calls to print
k
() to see
+ between a pair of threads. Insert calls to print
f
() to see
what's going on. */
void
sema_self_test (void)
{
what's going on. */
void
sema_self_test (void)
{
- struct thread *thread;
struct semaphore sema[2];
int i;
struct semaphore sema[2];
int i;
- print
k
("Testing semaphores...");
+ print
f
("Testing semaphores...");
sema_init (&sema[0], 0, "ping");
sema_init (&sema[1], 0, "pong");
sema_init (&sema[0], 0, "ping");
sema_init (&sema[1], 0, "pong");
- thread
= thread_create ("sema-test"
, sema_test_helper, &sema);
+ thread
_create ("sema-test", PRI_DEFAULT
, sema_test_helper, &sema);
for (i = 0; i < 10; i++)
{
sema_up (&sema[0]);
sema_down (&sema[1]);
}
for (i = 0; i < 10; i++)
{
sema_up (&sema[0]);
sema_down (&sema[1]);
}
- print
k
("done.\n");
+ print
f
("done.\n");
}
/* Thread function used by sema_self_test(). */
}
/* Thread function used by sema_self_test(). */
@@
-162,7
+162,6
@@
lock_init (struct lock *lock, const char *name)
ASSERT (lock != NULL);
ASSERT (name != NULL);
ASSERT (lock != NULL);
ASSERT (name != NULL);
- strlcpy (lock->name, name, sizeof lock->name);
lock->holder = NULL;
sema_init (&lock->semaphore, 1, name);
}
lock->holder = NULL;
sema_init (&lock->semaphore, 1, name);
}
@@
-226,7
+225,7
@@
lock_name (const struct lock *lock)
{
ASSERT (lock != NULL);
{
ASSERT (lock != NULL);
- return
lock->name
;
+ return
sema_name (&lock->semaphore)
;
}
\f
/* One semaphore in a list. */
}
\f
/* One semaphore in a list. */