Embedded Systems September 2000 Vol13_10

Issue link:

Contents of this Issue


Page 53 of 229

passin g, synchronization, mutual- exclusion, and more. Mo t commercial real-time kernels are preemptive. A preemptive ke rnel ensures that the highest-priori ty task that is ready to run is given control of the CPU. When an ISR makes a high- er priority task ready to run, the high- er priority ta k wi ll be given control of the CPU as soon as all nested in ter- rupts complete. The execution profil e of a system designed using a preemp- tive kernel is illustrated in Figure 2. As shown, a low p• ·iority task is executing FIGURE 1 Main Register Set l il IX IY SP PC 16-Bits ir l rr· - -;;..--- B' , - -- -- H' Alternate Register Set ---------- R ------- - D' -1 ----------- FIGURE 2 Execution profile of a P.reemP.tive kernel 3 ISR - · F' C' E' (1). An asynchronous event interrupts th e microprocessor and the processor vectors to an ISR (2). The micro- processor services the event (3) and calls a se rvice, provided by the kernel, that causes a higher priority task to become ready for execution. Most likely, the higher priori ty task was wait- ing for the ISR to occur. Upon com- pletion of the ISR, the ke rnel is invoked once more. This time, the kernel notices that a higher priority task is now ready to run and thus, the processor cannot return to the inter- rupted task. Instead, th e kernel will resume the high priority task ( 4). The higher priori ty task executes (5) until it again needs to be signaled by anoth- er occurrence of the ISR or another task. A kernel se rvice is again invoked to have the high priori ty task wait for an event. lf tJ1e event did not occur, the kernel resumes execution of the lower priority t.:"lsk (6). A kernel thus ensures that time crit- tasks are per formed first. ical Furthermore, execution of time-criti- cal tasks are deterministic and at·e almost insensitive to code changes. In fact, you can often add and change low priori ty tasks witJ1out affecting tJ1e responsiveness of your system to high priority tasks. In order to manage ta ks, the ker- High priority tast Low priority task ~---------~ Time FIGURE 3 t:ist of tasks waiting to be executed · , · . Ready List · · · · · ··· .,~ · : · · '· · - · · 0 nel needs to main tain inte rnal data st.-uctures. One such data structure is called the task control block (TCB) . Each task is assigned a TCB by the ke r- nel. A TCB contains the "state" of a task (ready or waiting) , the current location of the task's to p-of-stack (TOS), priori ty, and other kernel-spe- cific elemen ts. Because each task is assigned a pri- Highest priority Lowest priority ori ty, the kernel must also keep track of tasks in order of priori ty. The kernel mai ntains what's called a Ready List. The ready list tells the kernel which tasks are able to execute. The kernel always chooses the highest priori ty task that is ready to run. Only one task can execute on the processor at any given time, and thus, the od1er tasks that are ready will have to wait until 52 SEPTEMBER 2000 Embedded Systems Programming

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems September 2000 Vol13_10