hardclock

hardclock - */ lbolt_counter++; if (lbolt_counter...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <types.h> #include <lib.h> #include <machine/spl.h> #include <thread.h> #include <clock.h> /* * The address of lbolt has thread_wakeup called on it once a second. */ int lbolt; static int lbolt_counter; /* * This is called HZ times a second by the timer device setup. */ void hardclock(void) { /* * Collect statistics here as desired.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: */ lbolt_counter++; if (lbolt_counter &gt;= HZ) { lbolt_counter = 0; thread_wakeup(&amp;lbolt); } thread_yield(); } /* * Suspend execution for n seconds. */ void clocksleep(int num_secs) { int s; s = splhigh(); while (num_secs &gt; 0) { thread_sleep(&amp;lbolt); num_secs--; } splx(s); }...
View Full Document

Ask a homework question - tutors are online