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)
26 print("eqlock: %#p: nlocks %d\n", getcallerpc(&q), up->nlocks);
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);
55 up->qpc = getcallerpc(&q);
71 if(m->ilockdepth != 0)
72 print("qlock: %#p: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
73 if(up != nil && up->nlocks)
74 print("qlock: %#p: nlocks %d\n", getcallerpc(&q), up->nlocks);
75 if(up != nil && up->eql)
76 print("qlock: %#p: eql %p\n", getcallerpc(&q), up->eql);
77 if(q->use.key == 0x55555555)
78 panic("qlock: q %#p, key 5*", q);
98 up->qpc = getcallerpc(&q);
106 if(!canlock(&q->use))
124 print("qunlock called with qlock not held, from %#p\n",
146 if(q->writer == 0 && q->head == nil){
147 /* no writer, go for it */
163 up->state = QueueingR;
175 if(--(q->readers) > 0 || p == nil){
180 /* start waiting writer */
181 if(p->state != QueueingW)
198 if(q->readers == 0 && q->writer == 0){
199 /* noone waiting, go for it */
200 q->wpc = getcallerpc(&q);
218 up->state = QueueingW;
235 if(p->state == QueueingW){
236 /* start waiting writer */
245 if(p->state != QueueingR)
248 /* waken waiting readers */
249 while(q->head != nil && q->head->state == QueueingR){
261 /* same as rlock but punts if there are any writers waiting */
267 if(q->writer == 0 && q->head == nil){
268 /* no writer, go for it */