/* clkhandler.c - clkhandler */
#include
/*------------------------------------------------------------------------
* clkhandler - high level clock interrupt handler
*------------------------------------------------------------------------
*/
void clkhandler(
int32 arg /* Interrupt handler argument */
)
{
if(!(hpet->gis & HPET_GIS_T0)) {
return;
}
hpet->gis |= HPET_GIS_T0;
/* Decrement the ms counter, and see if a second has passed */
if((++count1000) >= 1000) {
/* One second has passed, so increment seconds count */
clktime++;
/* Reset the local ms counter for the next second */
count1000 = 0;
}
/* Handle sleeping processes if any exist */
if(!isempty(sleepq)) {
/* Decrement the delay for the first process on the */
/* sleep queue, and awaken if the count reaches zero */
if((--queuetab[firstid(sleepq)].qkey) <= 0) {
wakeup();
}
}
/* Decrement the preemption counter, and reschedule when the */
/* remaining time reaches zero */
if((--preempt) <= 0) {
preempt = QUANTUM;
resched();
}
}