热门

最新

红包

立Flag

投票

同城

我的

发布
qq_55062745
古月子小
3 年前
trueqq_55062745

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

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
t->base_priority=priority; list_init(&t->locks); t->lock_waiting=NULL;
立即登录