void
lock_ acquire (struct lock *lock)
struct thread *current_ thread = thread_ current ();struct lock *l;
enum intr, level old_ level;
ASSERT (lock != NULL);
ASSERT (!intr_ context ( ) ;
ASSERT (!1ock_ held _by_ current_ thread (lock));//-
new-
if (lock->holder != NULL && !thread_ mlfqs)
current_ thread->lock_ _waiting = lock;
1 = lock;
11 kLFil 1HH18
while (1 && current_ thread->priority , 1->max_ priority)f
1->max_ priority = current_ thread- >priority;
thread_ _donate_ priority (l->holder);
1 = l->holder->lock_ _waiting;
//Pf/FZ iALHi11H4
sema_ down ( &lock- >semaphore) ;
old_ level = intr_ disable ( );
current_ thread = thread_ current ();if (!thread_ mlfqs)
current_ thread->lock_ _waiting = NULL;
lock->max_ priority = current_ thread- »priority;//被唤醒之后让该线程成为这个锁的持有者
thread_ hold_ the_ lock (lock);
lock->holder = current_ thread;intr_ set_ level (old_ level);
CSDN @Polal