X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fthreads%2Fsynch.c;h=10a7dad5d022f7a294e5cce95d0a3dfb1148be73;hb=0c9836a6422fe07c539bd0f08965011a7b164b0e;hp=28696d471aecfc67bfffc243f3734b0dd34a09b2;hpb=4ae5b813663cd56fcbe1f1f547c9d445e5dc6107;p=pintos-anon diff --git a/src/threads/synch.c b/src/threads/synch.c index 28696d4..10a7dad 100644 --- a/src/threads/synch.c +++ b/src/threads/synch.c @@ -162,7 +162,6 @@ lock_init (struct lock *lock, const char *name) ASSERT (lock != NULL); ASSERT (name != NULL); - strlcpy (lock->name, name, sizeof lock->name); lock->holder = NULL; sema_init (&lock->semaphore, 1, name); } @@ -193,8 +192,8 @@ lock_acquire (struct lock *lock) /* Releases LOCK, which must be owned by the current thread. An interrupt handler cannot acquire a lock, so it does not - make sense to try to signal a condition variable within an - interrupt handler. */ + make sense to try to release a lock within an interrupt + handler. */ void lock_release (struct lock *lock) { @@ -226,7 +225,7 @@ lock_name (const struct lock *lock) { ASSERT (lock != NULL); - return lock->name; + return sema_name (&lock->semaphore); } /* One semaphore in a list. */ @@ -251,7 +250,7 @@ cond_init (struct condition *cond, const char *name) } /* Atomically releases LOCK and waits for COND to be signaled by - some other piece of code. After COND is signalled, LOCK is + some other piece of code. After COND is signaled, LOCK is reacquired before returning. LOCK must be held before calling this function. @@ -262,7 +261,7 @@ cond_init (struct condition *cond, const char *name) again. A given condition variable is associated with only a single - lock, but one lock may be be associated with any number of + lock, but one lock may be associated with any number of condition variables. That is, there is a one-to-many mapping from locks to condition variables.