Page 257 - Embedded Microprocessor Systems Real World Design
P. 257

operations, such as activating a task. Knowing this, you can predict the impact the
                   RTOS will have on system performance.
                     An RTOS comes in two basic flavors: kernels and full operating systems. A kernel
                   usually  implements  the  basic  task  and  memory  management  functions.  A  full
                   operating system may have drivers for disk drives, serial ports, and other common
                   resources. One common characteristic of RTOSs is that the system hardware must
                   generate a regular interrupt (called a timer tick or just a tick), say, at 20Hz (50ms).
                   This is used for timekeeping, task scheduling, and other functions. Not all RTOSs
                   require a system timer interrupt. Real-time operating systems typically support the
                   following functions:

                     Multitasking, which includes:
                       Activation and deactivation of tasks
                       Setting task priorities
                       Scheduling tasks

                     Communication between tasks
                     Memory management





                   Multitasking


                   This is the process of scheduling tasks or processes so that they all appear to operate
                   simultaneously. In the protocol converter example, the receive, XON, output, and
                   XOFF processes appear to a human user to run simultaneously because the sequen-
                   tial, one-at-a-time operation is so fast. All the functions of task activation/deactiva-
                   tion, scheduling, and ranking are part of the multitasking function. In a sequential
                   program, none  of  these operations, which are required  for  true multitasking, is
                   implemented.
                      Multitasking also can be implemented by  time slicing. In this method, tasks are
                   switched every tick. Every time the interrupt occurs, a different task is given control,
                   so each task gets to execute for one tick time  (50ms for the 20Hz tick example
                   given  previously). The overall execution  speed for  a given  task depends on the
                   number of tasks. Higher-priority tasks can be allowed to execute for more than one
                   tick time. A task that needs less than a full tick to execute can terminate early, giving
                   the remainder of its time to the next task.
                      Sequential  scheduling  and  time  slicing are  essentially the  same  except  that
                   sequentially scheduled tasks run until finished and time-sliced tasks run until their
                   time is up. Tasks operating under either scheduling scheme can voluntarily relin-
                   quish control before finishing. In that case, they can be restarted where they left
                   off instead of starting over.


                   238                                             Embedded Microprocessor Systemr
   252   253   254   255   256   257   258   259   260   261   262