Download Embedded Multitasking with small - innovated

Transcript
260
Chapter 4
There are three aspects to this system that a designer should question:
one, how can a task maintain constant timing, if it cannot be guaranteed
execution time in a specific tick? Two, does the system give a preference
for the best fit in the time remaining, or on the basis of priority? And,
three, how does the system respond to changes in the system mode? One:
fixed timing can only be guaranteed by using a buffered input/output
system that is tied to the main system timer. Two: the tasks are tested
in the order they are encoded into the design of the priority handler, so
tasks that are tested earlier in the tick have higher priority than tasks that
are tested later in the list. As a result, order of testing translates directly
to priority, however, if a higher priority task will not fit into the time
remaining, it will be bypassed for a lower priority task that does fit in
the time remaining. And, three: like the passive priority handler, there
is no mechanism for changing the priorities of the system based on the
system mode. However, combining this system with one of the later
priority handlers does give the system that capability.
One other question that should come up: doesn’t the testing in the
priority handler also decrease the time remaining in the tick? The answer
is yes, it does, and, yes, it will affect the calculation of time remaining
for each subsequent task that is tested. However, after each test, the remaining time can either be retrieved again from the system timer, or be
offset by the test time through a simple subtraction from the test value.
This will compensate for the time required to perform the last test, and
keep the time-remaining value current for each new test.
While this system does get the optimum execution throughput out
of the system, in many applications, the additional design and test
overhead, plus the execution time required to determine which task
should execute is often such a drain on the throughput that a point of
diminishing returns is reached. When this happens, the priority handler
is consuming more execution time than it saves and the system has no
value. So, the designer is encouraged to carefully consider the time and
resources required using this method of priority handler before investing
large amounts of time in its design. Remember, a priority handler’s job