r/kernel/clock.c

46 lines
1.1 KiB
C

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
clock.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Forrest Yu, 2005
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include "type.h"
#include "const.h"
#include "protect.h"
#include "proto.h"
#include "string.h"
#include "global.h"
/*======================================================================*
clock_handler
*======================================================================*/
PUBLIC void clock_handler(int irq)
{
ticks++;
p_proc_ready->ticks--;
if (k_reenter != 0) {
return;
}
if (p_proc_ready->ticks > 0) {
return;
}
schedule();
}
/*======================================================================*
milli_delay
*======================================================================*/
PUBLIC void milli_delay(int milli_sec)
{
int t = get_ticks();
while(((get_ticks() - t) * 1000 / HZ) < milli_sec) {}
}