2 #include "../port/lib.h"
21 if(m->ilockdepth != 0)
22 print("qlock: %#p: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
23 if(up != nil && up->nlocks.ref)
24 print("qlock: %#p: nlocks %lud\n", getcallerpc(&q), up->nlocks.ref);
26 if(q->use.key == 0x55555555)
27 panic("qlock: q %#p, key 5*\n", q);
46 up->qpc = getcallerpc(&q);
72 print("qunlock called with qlock not held, from %#p\n",
94 if(q->writer == 0 && q->head == nil){
95 /* no writer, go for it */
111 up->state = QueueingR;
123 if(--(q->readers) > 0 || p == nil){
128 /* start waiting writer */
129 if(p->state != QueueingW)
146 if(q->readers == 0 && q->writer == 0){
147 /* noone waiting, go for it */
148 q->wpc = getcallerpc(&q);
166 up->state = QueueingW;
183 if(p->state == QueueingW){
184 /* start waiting writer */
193 if(p->state != QueueingR)
196 /* waken waiting readers */
197 while(q->head != nil && q->head->state == QueueingR){
209 /* same as rlock but punts if there are any writers waiting */
215 if(q->writer == 0 && q->head == nil){
216 /* no writer, go for it */