qlock()

qlock()

概要

実装

   16: void
   17: qlock(QLock *q)
   18: {
   19:         Proc *p;
   20: 
   21:         if(m->ilockdepth != 0)
   22:                 print("qlock: %lux: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
   23:         if(up != nil && up->nlocks.ref)
   24:                 print("qlock: %lux: nlocks %lud\n", getcallerpc(&q), up->nlocks.ref);
   25: 
   26:         if(q->use.key == 0x55555555)
   27:                 panic("qlock: q %p, key 5*\n", q);
   28:         lock(&q->use);
   29:         rwstats.qlock++;
   30:         if(!q->locked) {
   31:                 q->locked = 1;
   32:                 unlock(&q->use);
   33:                 return;
   34:         }
   35:         if(up == 0)
   36:                 panic("qlock");
   37:         rwstats.qlockq++;
   38:         p = q->tail;
   39:         if(p == 0)
   40:                 q->head = up;
   41:         else
   42:                 p->qnext = up;
   43:         q->tail = up;
   44:         up->qnext = 0;
   45:         up->state = Queueing;
   46:         up->qpc = getcallerpc(&q);
   47:         unlock(&q->use);
   48:         sched();
   49: }