Permalink
Browse files

third step

  • Loading branch information...
1 parent 71748d0 commit a2b18691ee07d18d88db565bc167cde5a557a52d @grantborthwick committed Oct 5, 2012
Showing with 16 additions and 2 deletions.
  1. +16 −2 src/threads/synch.c
View
18 src/threads/synch.c
@@ -222,13 +222,27 @@ lock_init (struct lock *lock)
void
lock_acquire (struct lock *lock)
{
+ enum intr_level old_level;
ASSERT (lock != NULL);
ASSERT (!intr_context ());
ASSERT (!lock_held_by_current_thread (lock));
-
+ if ((lock->holder)!= NULL){
+ thread_current ()->want_lock = lock;
+ struct thread* donee = lock->holder;
+ thread_current ()->donee = donee;
+ list_push_front(&donee->benefactors, thread_current ());
+ }
+ //thread_recompute_priority(thread_current ()->donee);
+
sema_down (&lock->semaphore);
+
+ //old_level = intr_disable ();
+ //list_remove(
+ //thread_recompute_priority(thread_current ()->donee);
+ thread_current ()->donee = NULL;
+ thread_current ()->want_lock = NULL;
lock->holder = thread_current ();
- //list_push_front(&(thread_current ()->locks), lock);
+ //intr_set_level (old_level);
}
/* Tries to acquires LOCK and returns true if successful or false

0 comments on commit a2b1869

Please sign in to comment.