Task scheduling and the use of the kernel timer
fn multiJtasking lpsI many tasks run at the same timeK Providing WKH aSSroSriaWH rHsourFH Wo WKH Wask is FaOOHd task scheduling. qhe tool that distributes the available resources to the tasks is called a task schedulerK qhis is also called the PROCESS SCHEDULER, and is the part of the kernel that decides wKiFK Wask Wo run nHxW. ,W is onH oI WKH HssHnWiaO IaFWors oI a multiJtasking lpK lne feature many drivers need is the ability Wo sFKHduOH WKH HxHFuWion oI somH Wasks aW a OaWHr WimH wiWKouW rHsorWing Wo inWHrruSWs. /inux oIIHrs WKrHH diIIHrHnW inWHrIaFHs for this purposeW task QUEUES, TASKLETS, and kernel timers.
qask queues and tasklets SrovidH a flHxiEOH uWiOiWy Ior sFKHduOing HxHFuWion aW a OaWHr WimH, and arH WriggHrHd Ey WKH kHrnHO iWsHOI. TKHy arH onOy usHd Wo managH KardwarH WKaW FannoW gHnHraWH inWHrruSWs. TKHy aOways run in WKH inWHrruSW timeK And run only onceI though scheduled to run multiple timesK hernel timers are used to schedule a task to run at a sSHFifiF WimH in WKH IuWurH. MorHovHr, WKHy arH Hasy Wo usH, and also do not reJregister themselvesI unlike task queues that doK
AW WimHs, onH nHHds Wo HxHFuWH oSHraWions dHWaFKHd Irom any SroFHss FonWHxW, OikH finisKing a OHngWKy sKuWdown operationK fn that caseI delaying the return from the close() (WKH IunFWion Ior FOosing WKH fiOH dHsFriSWor; iW rHWurns 0 or 1 Ior suFFHss, r Ior IaiOurH, HWF) wouOdn’W EH Iair Wo WKH aSSOiFaWion Srogram. Using a Wask queue wouOd EH wasWHIuO, because a queued task must continually reJregister itself until the requisite time has passedK
qhe kernel timers are organised as a double linked listK add_timer and del_timer are the functions used to add and