15 static Channel* ctimer; /* chan(Timer*)[100] */
22 return nsec()/1000000;
42 int i, nt, na, dt, del;
46 threadsetname("timerproc");
53 sleep(1); /* will sleep minimum incr */
57 if(dt < 0) /* timer wrapped; go around, losing a tick */
68 * avoid possible deadlock if client is
69 * now sending on ctimer
71 if(nbsendul(x->c, 0) > 0)
75 memmove(&t[i], &t[i+1], (nt-i-1)*sizeof t[0]);
85 t = erealloc(t, na*sizeof(Timer*));
90 if(nbrecv(ctimer, &x) > 0)
98 ctimer = chancreate(sizeof(Timer*), 100);
99 proccreate(timerproc, nil, STACK);
111 t = emalloc(sizeof(Timer));
112 t->c = chancreate(sizeof(int), 0);