Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The sysctl_debug_sleep_test function obtains events from the sysctl debug.sleep.test. It then passes those events to the sleep_thread function.
static int
sysctl_debug_sleep_test(SYSCTL_HANDLER_ARGS)
{
int error, i = 0;
error =
sysctl_handle_int(oidp,
&i, 0, req);
if (error == 0 && req->newptr != NULL) {
if (i >= 1 && i <= MAX_EVENT) {
mtx_lock(&event_mtx);
KASSERT(event == 0, ("event %d was unhandled",
event));
event = i;
cv_signal(&event_cv);
mtx_unlock(&event_mtx);
} else
error = EINVAL;
}
return (error);
}