Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_clock.c
Show First 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | |||||
int stathz; | int stathz; | ||||
int profhz; | int profhz; | ||||
int profprocs; | int profprocs; | ||||
volatile int ticks; | volatile int ticks; | ||||
int psratio; | int psratio; | ||||
static DPCPU_DEFINE(int, pcputicks); /* Per-CPU version of ticks. */ | static DPCPU_DEFINE(int, pcputicks); /* Per-CPU version of ticks. */ | ||||
static int global_hardclock_run = 0; | #ifdef DEVICE_POLLING | ||||
static int devpoll_run = 0; | |||||
#endif | |||||
/* | /* | ||||
* Initialize clock frequencies and start both clocks running. | * Initialize clock frequencies and start both clocks running. | ||||
*/ | */ | ||||
/* ARGSUSED*/ | /* ARGSUSED*/ | ||||
static void | static void | ||||
initclocks(dummy) | initclocks(dummy) | ||||
void *dummy; | void *dummy; | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | |||||
#ifdef HWPMC_HOOKS | #ifdef HWPMC_HOOKS | ||||
if (PMC_CPU_HAS_SAMPLES(PCPU_GET(cpuid))) | if (PMC_CPU_HAS_SAMPLES(PCPU_GET(cpuid))) | ||||
PMC_CALL_HOOK_UNLOCKED(curthread, PMC_FN_DO_SAMPLES, NULL); | PMC_CALL_HOOK_UNLOCKED(curthread, PMC_FN_DO_SAMPLES, NULL); | ||||
if (td->td_intr_frame != NULL) | if (td->td_intr_frame != NULL) | ||||
PMC_SOFT_CALL_TF( , , clock, hard, td->td_intr_frame); | PMC_SOFT_CALL_TF( , , clock, hard, td->td_intr_frame); | ||||
#endif | #endif | ||||
/* We are in charge to handle this tick duty. */ | /* We are in charge to handle this tick duty. */ | ||||
if (newticks > 0) { | if (newticks > 0) { | ||||
/* Dangerous and no need to call these things concurrently. */ | |||||
if (atomic_cmpset_acq_int(&global_hardclock_run, 0, 1)) { | |||||
tc_ticktock(newticks); | tc_ticktock(newticks); | ||||
#ifdef DEVICE_POLLING | #ifdef DEVICE_POLLING | ||||
/* Dangerous and no need to call these things concurrently. */ | |||||
if (atomic_cmpset_acq_int(&devpoll_run, 0, 1)) { | |||||
/* This is very short and quick. */ | /* This is very short and quick. */ | ||||
hardclock_device_poll(); | hardclock_device_poll(); | ||||
#endif /* DEVICE_POLLING */ | atomic_store_rel_int(&devpoll_run, 0); | ||||
atomic_store_rel_int(&global_hardclock_run, 0); | |||||
} | } | ||||
#endif /* DEVICE_POLLING */ | |||||
#ifdef SW_WATCHDOG | #ifdef SW_WATCHDOG | ||||
if (watchdog_enabled > 0) { | if (watchdog_enabled > 0) { | ||||
i = atomic_fetchadd_int(&watchdog_ticks, -newticks); | i = atomic_fetchadd_int(&watchdog_ticks, -newticks); | ||||
if (i > 0 && i <= newticks) | if (i > 0 && i <= newticks) | ||||
watchdog_fire(); | watchdog_fire(); | ||||
} | } | ||||
#endif /* SW_WATCHDOG */ | #endif /* SW_WATCHDOG */ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines |