コード例 #1
0
ファイル: devfloppy.c プロジェクト: biddyweb/plan9
static void
timedsleep(int (*f)(void*), void* arg, int ms)
{
    int s;
    ulong end;

    end = m->ticks + 1 + MS2TK(ms);
    while(m->ticks < end && !(*f)(arg)) {
        s = spllo();
        delay(10);
        splx(s);
    }
}
コード例 #2
0
ファイル: proc.c プロジェクト: 8l/inferno
void
tsleep(Rendez *r, int (*fn)(void*), void *arg, int ms)
{
	ulong when;
	Proc *f, **l;

	if(up == nil)
		panic("tsleep() not in process (0x%lux)", getcallerpc(&r));

	when = MS2TK(ms)+MACHP(0)->ticks;
	lock(&talarm);
	/* take out of list if checkalarm didn't */
	if(up->trend) {
		l = &talarm.list;
		for(f = *l; f; f = f->tlink) {
			if(f == up) {
				*l = up->tlink;
				break;
			}
			l = &f->tlink;
		}
	}
	/* insert in increasing time order */
	l = &talarm.list;
	for(f = *l; f; f = f->tlink) {
		if(f->twhen >= when)
			break;
		l = &f->tlink;
	}
	up->trend = r;
	up->twhen = when;
	up->tfn = fn;
	up->tlink = *l;
	*l = up;
	unlock(&talarm);

	if(waserror()){
		up->twhen = 0;
		nexterror();
	}
	sleep(r, tfn, arg);
	up->twhen = 0;
	poperror();
}
コード例 #3
0
ファイル: devaoe.c プロジェクト: Earnestly/plan9
	Eventlen 	= 256,
	Nevents 	= 64,			/* must be power of 2 */

	Fread		= 0,
	Fwrite,
	Tfree		= -1,
	Tmgmt,

	/*
	 * round trip bounds, timeouts, in ticks.
	 * timeouts should be long enough that rebooting
	 * the coraid (which usually takes under two minutes)
	 * doesn't trigger a timeout.
	 */
	Rtmax		= MS2TK(320),
	Rtmin		= MS2TK(20),
	Maxreqticks	= 4*60*HZ,		/* was 45*HZ */

	Dbcnt		= 1024,

	Crd		= 0x20,
	Crdext		= 0x24,
	Cwr		= 0x30,
	Cwrext		= 0x34,
	Cid		= 0xec,
};

enum {
	Read,
	Write,