hardclock - lbolt_counter if(lbolt_counter>= HZ...

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 >= HZ) { lbolt_counter = 0; thread_wakeup(&lbolt); } thread_yield(); } /* * Suspend execution for n seconds. */ void clocksleep(int num_secs) { int s; s = splhigh(); while (num_secs > 0) { thread_sleep(&lbolt); num_secs--; } splx(s); }...
View Full Document

This note was uploaded on 11/10/2009 for the course CS 536 taught by Professor Lums during the Spring '09 term at Indiana.

Ask a homework question - tutors are online