/* * The real-time timer, interrupting hz times per second. */ void uinet_hardclock(void) { atomic_add_int((volatile int *)&ticks, 1); /* hardclock_cpu(usermode); * * There is no need for the process accounting done in * hardclock_cpu(). We only need the callout_tick() call, which is * reproduced below. */ callout_tick(); tc_ticktock(1); /* cpu_tick_calibration(); * * There is no need for cpu_tick_calibration(), as we are operating * as a fixed-rate ticker. */ /* * If no separate statistics clock is available, run it from here. * * XXX: this only works for UP */ /* if (stathz == 0) { * profclock(usermode, pc); * statclock(usermode); * } * * No need for profclock or statclock support. */ #ifndef UINET /* No DEVICE_POLLING or SW_WATCHDOG support under UINET */ #ifdef DEVICE_POLLING hardclock_device_poll(); /* this is very short and quick */ #endif /* DEVICE_POLLING */ #ifdef SW_WATCHDOG if (watchdog_enabled > 0 && --watchdog_ticks <= 0) watchdog_fire(); #endif /* SW_WATCHDOG */ #endif /* UINET */ }
void* clock_intr_handler(void* arg) { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000; while(1){ bsd_ticks ++; callout_tick(); host_thread_enter_wait_region(); nanosleep(&ts, NULL); host_thread_exit_wait_region(); } return NULL; }