void lock(struct lock *l) { struct proc *p; if (up == nil) { return; } retry: if (!cas(&l->holder, nil, up)) { p = l->wlist; while (p != nil && p->next != nil) p = p->next; up->next = nil; if (p == nil) { if (!cas(&l->wlist, nil, up)) { goto retry; } } else if (!cas(&p->next, nil, up)) { goto retry; } procwait(); } }
Waitmsg* runprocfd(char *file, char **v, int fd[3]) { int pid, i; threadwaitchan(); pid = threadspawn(fd, file, v); for(i=0; i<3; i++) close(fd[i]); if(pid < 0) return nil; return procwait(pid); }
bool procwaitintr(int irqn) { intrstate_t t; if (irqn < 0 || irqn > nirq) { return false; } else if (handlers[irqn] != nil) { return false; } if (!cas(&waiting[irqn], nil, up)) { return false; } t = setintr(INTR_off); unmaskintr(irqn); procwait(); setintr(t); return true; }