13 static Channel* ctimer; /* chan(Timer*)[100] */
20 return nsec()/1000000;
40 int i, nt, na, dt, del;
45 threadsetname("TIMERPROC");
51 sleep(1); /* will sleep minimum incr */
55 if(dt < 0) /* timer wrapped; go around, losing a tick */
66 * avoid possible deadlock if client is
67 * now sending on ctimer
69 if(nbsendul(x->c, 0) > 0)
73 memmove(&t[i], &t[i+1], (nt-i-1)*sizeof t[0]);
83 t = realloc(t, na*sizeof(Timer*));
90 if(nbrecv(ctimer, &x) > 0)
98 ctimer = chancreate(sizeof(Timer*), 100);
99 proccreate(timerproc, nil, STACK);
103 * timeralloc() and timerfree() don't lock, so can only be
104 * called from the main proc.
116 t = emalloc(sizeof(Timer));
117 t->c = chancreate(sizeof(int), 0);