static void floppyalarm(Alarm* a) { FDrive *dp; for(dp = fl.d; dp < &fl.d[fl.ndrive]; dp++) { if((fl.motor&MOTORBIT(dp->dev)) && TK2SEC(m->ticks - dp->lasttouched) > 5) floppyoff(dp); } alarm(5*1000, floppyalarm, 0); cancel(a); }
static void floppykproc(void *) { FDrive *dp; while(waserror()) ; for(;;){ for(dp = fl.d; dp < &fl.d[fl.ndrive]; dp++){ if((fl.motor&MOTORBIT(dp->dev)) && TK2SEC(m->ticks - dp->lasttouched) > 5 && canqlock(&fl)){ if(TK2SEC(m->ticks - dp->lasttouched) > 5) floppyoff(dp); qunlock(&fl); } } tsleep(&up->sleep, return0, 0, 1000); } }