Information Technology Reference
In-Depth Information
With an interrupt handling system, a peripheral piece of hardware may cause
an interrupt to occur on the system. The operating system will then save the data
from the interrupt and schedule the task that processes the data. When going from
user to kernel mode, the data specific to a task usually is saved to a task control
block or TCB. When a task is scheduled to run, the information contained in the
TCB is loaded into the registers and program counter. This puts the system in the
same state as when the task finished running. The TCB is an alternative to the stack
approach. A drawback of the stack approach is its rigid, first-in last-out structure. If
the scheduling of tasks requires more flexibility, it may be beneficial to design the
operating system to manage task scheduling by TCB rather than by a stack. Each
TCB points to the next TCB that is scheduled to execute. If during execution of the
current task, the execution order needs to change, it easily can be accomplished by
changing the address of the next task in the TCB. Table 3.3 shows task management
design options and a comparison.
3.4
TASK SCHEDULING: SCHEDULING ALGORITHMS
In real-time embedded systems, usually only one application is running on a micro-
processor. However, there may be many tasks that make up an application and the
operating system must have a method for scheduling tasks so that the overall needs
of the system are met. The real-time system is responsible for performing a certain
function. For example, with motor controls, the purpose of the embedded system is to
control an electric motor. Many subroutines or tasks contribute to the motor control
application. But the responsibilities of the application usually are broken down func-
tionally into smaller pieces; these pieces are referred to as tasks. Going back to the
example of a motor control application, one task may be responsible for controlling
the current going to the motor where another task may be responsible for controlling
the state of the system. And yet another task may be responsible for diagnostics. Each
of these tasks has varied priorities and may need to run at different task rates. Some
tasks may need to run more often than others, and tasks may need different priorities
assigned to them. If the system has periodic tasks that run at certain intervals such as
every 1 ms, 10 ms, or 100 ms, two or more tasks may need to run at the same time. The
operating system uses priorities to determine which task should be allowed to execute
on the CPU. This provides a method for the operating system to arbitrate between
multiple tasks that are requesting the CPU. Task scheduling is very important to the
success of a system, and an operating system must provide at least one method of
scheduling tasks.
3.4.1
Interrupt-Driven Systems
Interrupt-driven systems for real-time applications are one of the most prevalent
designs used in operating systems. Because time is critical to the success of the
system, interrupts allow the system to perform tasks on regular intervals, commonly
called periodic tasks. They address immediate needs that occur randomly, called
Search WWH ::




Custom Search