Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Implementing Sleeps and Condition Variables > sysctl_debug_sleep_test Function

sysctl_debug_sleep_test Function

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);
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial