This article explores how kernel functions and task scheduling are closely linked to time.
qime is vital for kernel programming since many kernel functions are timeJdrivenK pome are periodicI such as push and pull migration for loadJbalancingI the scheduler that runs queuesI or refreshing the screenK qheir IrHTuHnFiHs arH fixHd (suFK as 100 WimHs SHr sHFond). TKH kernel schedules other functionsI such as delayed disk fLlI aW a rHOaWivH WimH in WKH IuWurH. For HxamSOH, WKH kHrnHO migKW sFKHduOH a floSSy dHviFH drivHr Wo sKuW oII aIWHr WKH floSSy drivHr moWor EHFomHs inaFWivH; WKis Fan EH 50 miOOisHFonds (say) Irom now or aIWHr FomSOHWion oI a FHrWain Wask. So WKH kernel horology is relativeK qhe kernel must also manage the system uptimeI and the current date and timeK
EvHnWs WKaW oFFur SHriodiFaOOy HvHry 10 miOOisHFonds arH driven by the system timerK qhis is a programmable piece of KardwarH WKaW issuHs an inWHrruSW aW a fixHd IrHTuHnFy. TKH interrupt handler for this timer is called the timer interrupt. TKH KardwarH SrovidHs a sysWHm WimHr WKaW WKH kHrnHO usHs Wo gaugH WKH Sassing oI WimH, wKiFK works oII an HOHFWroniF time sourceI such as a digital clock or the frequency of the SroFHssor. TKH sysWHm WimHr goHs oII (oIWHn FaOOHd hitting or popping) at a preJprogrammed frequencyI called the tick rate. then the system timer goes offI it issues an interrupt that the kernel handles via a special interrupt handlerK Because the kHrnHO knows WKH SrH-SrogrammHd WiFk raWH, iW knows WKH WimH EHWwHHn any Wwo suFFHssivH WimHr inWHrruSWs. TKis SHriod is called a tick. TKis is Kow WKH kHrnHO kHHSs WraFk oI EoWK ‘waOO WimH’ and sysWHm uSWimH. ‘:aOO WimH’, wKiFK is WKH aFWuaO WimH of dayI is important to userJspace applicationsK qhe kernel keeps track of it simply because the kernel controls the timer inWHrruSW. TKH kHrnHO dHfinHs WKH vaOuH in <asm/param.h>. cor HxamSOH, a miFroSroFHssor wiWK an x86 arFKiWHFWurH Kas 100 Hz, wKHrHas onH wiWK WKH ,nWHO ,Wanium arFKiWHFWurH (HarOiHr ,A-64) Kas a 1024 Hz raWH.