| plan 9 kernel history: overview | file list | diff list |
1992/0807/port/tcptimer.c (diff list | history)
| port/tcptimer.c on 1992/0128 | ||
| 1992/0128 | #include "u.h" | |
| 1992/0321 | #include "../port/lib.h" | |
| 1991/0424 | #include "mem.h" #include "dat.h" #include "fns.h" | |
| 1992/0111 | #include "../port/error.h" | |
| 1991/0424 | #include "arp.h" #include "ipdat.h" /* Head of running timer chain */ Timer *timers; QLock timerlock; Rendez Tcpack; Rendez tcpflowr; void tcpackproc(void *junk) { Timer *t,*tp; Timer *expired; | |
| 1991/1115 | USED(junk); | |
| 1991/0424 | for(;;) { expired = 0; qlock(&timerlock); for(t = timers;t != 0; t = tp) { tp = t->next; if(tp == t) panic("Timer loop at %lux\n",(long)tp); | |
| 1992/0314 | if(t->state == TIMER_RUN) if(--(t->count) == 0){ | |
| 1991/0424 | /* Delete from active timer list */ if(timers == t) timers = t->next; if(t->next != 0) t->next->prev = t->prev; if(t->prev != 0) t->prev->next = t->next; t->state = TIMER_EXPIRE; /* Put on head of expired timer list */ t->next = expired; expired = t; } } qunlock(&timerlock); | |
| 1992/0314 | for(;;) { t = expired; if(t == 0) break; | |
| 1991/0424 | expired = t->next; | |
| 1992/0314 | if(t->state == TIMER_EXPIRE) if(t->func) | |
| 1991/0424 | (*t->func)(t->arg); } tsleep(&Tcpack, return0, 0, MSPTICK); } } void start_timer(Timer *t) { if(t == 0 || t->start == 0) return; qlock(&timerlock); t->count = t->start; if(t->state != TIMER_RUN){ t->state = TIMER_RUN; /* Put on head of active timer list */ t->prev = 0; t->next = timers; if(t->next != 0) t->next->prev = t; timers = t; } qunlock(&timerlock); } void stop_timer(Timer *t) { if(t == 0) return; qlock(&timerlock); if(t->state == TIMER_RUN){ /* Delete from active timer list */ if(timers == t) timers = t->next; if(t->next != 0) t->next->prev = t->prev; if(t->prev != 0) t->prev->next = t->next; } t->state = TIMER_STOP; qunlock(&timerlock); } void | |
| 1992/0626 | tcpflow(void *x) | |
| 1991/0424 | { | |
| 1992/0626 | Ipifc *ifc; Ipconv *cp, **p, **etab; | |
| 1991/0424 | ||
| 1992/0626 | ifc = x; etab = &ifc->conv[Nipconv]; | |
| 1992/0807 | ||
| 1991/0424 | for(;;) { sleep(&tcpflowr, return0, 0); | |
| 1992/0626 | for(p = ifc->conv; p < etab; p++) { cp = *p; if(cp == 0) break; | |
| 1992/0807 | if(cp->readq && cp->ref != 0 && !QFULL(cp->readq->next)) { | |
| 1992/0626 | tcprcvwin(cp); tcp_acktimer(cp); | |
| 1991/0424 | } } } } | |