Changeset View
Changeset View
Standalone View
Standalone View
head/sys/boot/kshim/bsd_kernel.c
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | cv_wait(struct cv *cv, struct mtx *mtx) | ||||
cv_timedwait(cv, mtx, -1); | cv_timedwait(cv, mtx, -1); | ||||
} | } | ||||
int | int | ||||
cv_timedwait(struct cv *cv, struct mtx *mtx, int timo) | cv_timedwait(struct cv *cv, struct mtx *mtx, int timo) | ||||
{ | { | ||||
int start = ticks; | int start = ticks; | ||||
int delta; | int delta; | ||||
int time = 0; | |||||
if (cv->sleeping) | if (cv->sleeping) | ||||
return (EWOULDBLOCK); /* not allowed */ | return (EWOULDBLOCK); /* not allowed */ | ||||
cv->sleeping = 1; | cv->sleeping = 1; | ||||
while (cv->sleeping) { | while (cv->sleeping) { | ||||
if (timo >= 0) { | if (timo >= 0) { | ||||
delta = ticks - start; | delta = ticks - start; | ||||
if (delta >= timo || delta < 0) | if (delta >= timo || delta < 0) | ||||
break; | break; | ||||
} | } | ||||
mtx_unlock(mtx); | mtx_unlock(mtx); | ||||
usb_idle(); | usb_idle(); | ||||
if (++time >= (1000000 / hz)) { | |||||
time = 0; | |||||
callout_process(1); | |||||
} | |||||
/* Sleep for 1 us */ | |||||
delay(1); | |||||
mtx_lock(mtx); | mtx_lock(mtx); | ||||
} | } | ||||
if (cv->sleeping) { | if (cv->sleeping) { | ||||
cv->sleeping = 0; | cv->sleeping = 0; | ||||
return (EWOULDBLOCK); /* not allowed */ | return (EWOULDBLOCK); /* not allowed */ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,076 Lines • Show Last 20 Lines |