00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <clock.h> 00011 00012 extern void wakeup(void); 00013 extern syscall resched(void); 00014 extern void restore_intr(void *); 00015 00020 interrupt clockintr(void) 00021 { 00022 clock_update(time_intr_freq); 00023 00024 /* Another millisecond has passed. */ 00025 ctr_mS--; 00026 00027 /* Update global second counter. */ 00028 if (0 == ctr_mS) 00029 { 00030 clocktime++; 00031 ctr_mS = 1000; 00032 } 00033 00034 /* If sleepq is not empty, decrement first key. */ 00035 /* If key reaches zero, call wakeup. */ 00036 if (nonempty(sleepq)) 00037 { 00038 if (--firstkey(sleepq) <= 0) 00039 restore_intr(&wakeup); 00040 } 00041 00042 /* Check to see if this proc should be preempted. */ 00043 if (--preempt <= 0) 00044 { 00045 restore_intr(&resched); 00046 } 00047 }