2 #include "../port/lib.h"
7 #include "../port/error.h"
23 if(m->ilockdepth != 0)
24 print("eqlock: %#p: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
25 if(up != nil && up->nlocks.ref)
26 print("eqlock: %#p: nlocks %lud\n", getcallerpc(&q), up->nlocks.ref);
27 if(up != nil && up->eql)
28 print("eqlock: %#p: eql %p\n", getcallerpc(&q), up->eql);
29 if(q->use.key == 0x55555555)
30 panic("eqlock: q %#p, key 5*", q);
54 up->qpc = getcallerpc(&q);
70 if(m->ilockdepth != 0)
71 print("qlock: %#p: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
72 if(up != nil && up->nlocks.ref)
73 print("qlock: %#p: nlocks %lud\n", getcallerpc(&q), up->nlocks.ref);
74 if(up != nil && up->eql)
75 print("qlock: %#p: eql %p\n", getcallerpc(&q), up->eql);
76 if(q->use.key == 0x55555555)
77 panic("qlock: q %#p, key 5*", q);
97 up->qpc = getcallerpc(&q);
105 if(!canlock(&q->use))
123 print("qunlock called with qlock not held, from %#p\n",
145 if(q->writer == 0 && q->head == nil){
146 /* no writer, go for it */
162 up->state = QueueingR;
174 if(--(q->readers) > 0 || p == nil){
179 /* start waiting writer */
180 if(p->state != QueueingW)
197 if(q->readers == 0 && q->writer == 0){
198 /* noone waiting, go for it */
199 q->wpc = getcallerpc(&q);
217 up->state = QueueingW;
234 if(p->state == QueueingW){
235 /* start waiting writer */
244 if(p->state != QueueingR)
247 /* waken waiting readers */
248 while(q->head != nil && q->head->state == QueueingR){
260 /* same as rlock but punts if there are any writers waiting */
266 if(q->writer == 0 && q->head == nil){
267 /* no writer, go for it */