// Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { structproc *p = myproc();
// Must acquire p->lock in order to // change p->state and then call sched. // Once we hold p->lock, we can be // guaranteed that we won't miss any wakeup // (wakeup locks p->lock), // so it's okay to release lk.
acquire(&p->lock); //DOC: sleeplock1 release(lk);
// Go to sleep. p->chan = chan; p->state = SLEEPING;
sched();
// Tidy up. p->chan = 0;
// Reacquire original lock. release(&p->lock); acquire(lk); }
In file included from user/sleep.c:1: user/user.h:36:1: 错误:unknown type name ‘uint’; did you mean ‘int’? 36 | uint strlen(const char*); | ^~~~ | int user/user.h:37:26: 错误:unknown type name ‘uint’; did you mean ‘int’? 37 | void* memset(void*, int, uint); | ^~~~ | int user/user.h:38:1: 错误:函数声明中出现形参名却未指定类型 [-Werror] 38 | void* malloc(uint); | ^~~~ user/user.h:41:40: 错误:unknown type name ‘uint’; did you mean ‘int’? 41 | int memcmp(const void *, const void *, uint); | ^~~~ | int user/user.h:42:36: 错误:unknown type name ‘uint’; did you mean ‘int’? 42 | void *memcpy(void *, const void *, uint); | ^~~~ | int cc1:所有的警告都被当作是错误