Linux 核心時鐘架構之時鐘源模組對外介面
既然時鐘源對外提供了計數能力,那麼可以通過哪些介面呢?
這裡需要唯一說明的是,整個時鐘源模組對外只有一個介面,即提供到timekeeping使用,其讀取計數值計數,計算時間。
核心函式是timekeeping_notify();
這個函式在選取合適的clocksource後被呼叫。
/**
* timekeeping_notify - Install a new clock source
* @clock: pointer to the clock source
*
* This function is called from clocksource.c after a new, better clock
* source has been registered. The caller holds the clocksource_mutex.
*/
int timekeeping_notify(struct clocksource *clock)
if (tk->tkr_mono.clock == clock) return 0; stop_machine(change_clocksource, clock, NULL); tick_clock_notify(); return tk->tkr_mono.clock == clock ? 0 : -1; }
當然在timer在oneshot模式下,即配置CONFIG_TICK_ONESHOT時,通知tick sched模組。
/**
* Async notification about clocksource changes
for_each_possible_cpu(cpu) set_bit(0, &per_cpu(tick_cpu_sched, cpu).check_clocks); }