sync with sources Reference: /n/atom/patch/applied/oventibits Date: Thu Mar 20 15:31:23 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/liboventi/plan9-thread.c Thu Mar 20 15:30:44 2014 +++ /sys/src/liboventi/plan9-thread.c Thu Mar 20 15:30:44 2014 @@ -25,6 +25,7 @@ int readers; /* number writering read lock */ Thread *qfirst; Thread *qlast; + uintptr pc; }; struct VtRendez { @@ -170,7 +171,7 @@ } /* - * RSC: I think the test is backward. Let's see who uses it. + * RSC: I think the test is backward. Let's see who uses it. * void vtLockInit(VtLock **p) @@ -238,6 +239,7 @@ Thread *t; lock(&p->lk); + p->pc = getcallerpc(&p); t = *vtRock; if(p->writer == nil && p->readers == 0) { p->writer = t; @@ -316,7 +318,7 @@ * venti currently has code that assumes lock can be passed between threads :-) * assert(p->writer == *vtRock); */ - assert(p->writer != nil); + assert(p->writer != nil); assert(p->readers == 0); t = p->qfirst; if(t == nil) { @@ -328,6 +330,7 @@ p->qfirst = t->next; p->writer = t; unlock(&p->lk); + threadWakeup(t); return; } @@ -337,6 +340,7 @@ tt = t; t = t->next; p->readers++; + threadWakeup(tt); } p->qfirst = t; @@ -357,7 +361,7 @@ return; } assert(t->state == QueuingW); - + p->qfirst = t->next; p->writer = t; unlock(&p->lk); @@ -421,7 +425,7 @@ * put on front so guys that have been waiting will not get starved */ p = q->lk; - lock(&p->lk); + lock(&p->lk); /* * venti currently has code that assumes lock can be passed between threads :-) * assert(p->writer == *vtRock); @@ -447,7 +451,7 @@ vtWakeupAll(VtRendez *q) { int i; - + for(i=0; vtWakeup(q); i++) ; return i;