From 06e49a58dcc8ba3f898ba5399449312cd129b0fe Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Sat, 20 Jul 2019 17:07:20 -0400 Subject: pi for pipe, rather than p, to avoid confusion with proc's p->lock --- kernel/proc.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'kernel/proc.c') diff --git a/kernel/proc.c b/kernel/proc.c index e63cc9f..bd39c4b 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -510,12 +510,6 @@ sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); - if(p == 0) - panic("sleep"); - - if(lk == 0) - panic("sleep without lk"); - // Must acquire p->lock in order to // change p->state and then call sched. // Once we hold p->lock, we can be @@ -543,17 +537,6 @@ sleep(void *chan, struct spinlock *lk) } } -//PAGEBREAK! -// Wake up p if it is sleeping in wait(); used by exit(). -// Caller must hold p->lock. -static void -wakeup1(struct proc *p) -{ - if(p->chan == p && p->state == SLEEPING) { - p->state = RUNNABLE; - } -} - // Wake up all processes sleeping on chan. // Must be called without any p->lock. void @@ -570,6 +553,16 @@ wakeup(void *chan) } } +// Wake up p if it is sleeping in wait(); used by exit(). +// Caller must hold p->lock. +static void +wakeup1(struct proc *p) +{ + if(p->chan == p && p->state == SLEEPING) { + p->state = RUNNABLE; + } +} + // Kill the process with the given pid. // The victim won't exit until it tries to return // to user space (see usertrap() in trap.c). -- cgit v1.2.3