void usemrelease(Usema *s) { if((int32)xadd(&s->u, 1) <= 0) { if(s->k == 0) initsema(&s->k); mach_semrelease(s->k); } }
void unlock(Lock *l) { m->locks--; if(m->locks < 0) throw("lock count"); if(xadd(&l->key, -1) > 0) { // someone else is waiting // Allocate semaphore if needed. if(l->sema == 0) initsema(&l->sema); mach_semrelease(l->sema); } }
void runtime·semawakeup(M *mp) { runtime·mach_semrelease(mp->waitsema); }