'''Intent:''' Ensure that desired operations are performed at specific points in the future. In RealTime systems, it is often necessary to ensure that something is done at a specific time. A scheduler object (note: not quite the same as SchedulerPattern) keeps track of these actions, and invokes them at the appropriate times. Times may be expressed as "wall time" or as some sort of internal time ("ticks", milliseconds-since-startup, etc.). If highly accurate scheduling of tasks is needed (to milliseconds or less), the scheduler task needs to run at a very high priority, or be hooked into a high-frequency interrupt routine. ''Is there another, more common name for this pattern?'' '''See also:''' CommandPattern, MementoPattern ---- On many common multitasking operating systems, the OS will allow you to start more and more processes, and each one will run slower and slower. A real-time task scheduler is specifically designed to provide real-time guarantees. The way it does that is (1) You tell it how often you want some task to run, and (2) it needs to know the *maximum* amount of time that task will run each time. Every time you ask it to run one more task, it analyzes the load it's already carrying, and if it cannot guarantee that all the tasks will continue to run at the desired rate, it refuses to add another task. ---- * harmonic task scheduling: basically, everything repeats at a "fundamental frequency", and every sliver of time is dedicated to some particular task or another. Tasks are assigned pieces based on their worst-case run-time. ---- The PPR has MartinFowler's "Recurring Events" document at http://c2.com/ppr/schedule.pdf ---- '''The RMA (rate monotonic algorithm)''' is a procedure for assigning fixed priorities to tasks ... A task is considered schedulable if all tasks meet all deadlines all the time. The algorithm is simple: * Assign the priority of each task according to its period, so that the shorter the period the higher the priority. RMA is the optimal fixed-priority algorithm. If a task set cannot be scheduled using the RMA algorithm, it cannot be scheduled using any fixed-priority algorithm. Sometimes a particular set of tasks will have a total utilization above the worst-case schedulable bound and still be schedulable with fixed priorities. Schedulability then ... must be analyzed by hand. Guidelines: ... Always assign priorities according to RMA. Manually assigning fixed priorities will not give you a better solution. If total utilization is less than or equal to [ ln(2) = 69.3% of CPU utilization], all tasks will meet all deadlines, so no additional work needs to be done. ... To achieve 100% CPU utilization when using fixed priorities, assign periods so that all tasks are harmonic. This means that for each task, its period is an exact multiple of every other task that has a shorter period. ... For example, a three-task set whose periods are 10, 20, and 40 ... is harmonic, and preferred over a task set with periods 10, 20, and 50. -- ''Rate Monotonic Scheduling'' article by David B. Stewart and Michael Barr in _Embedded Systems Programming_ 2002-03 See ''What is RMA?'' section of http://www.faqs.org/faqs/realtime-computing/faq/ ---- CategoryPattern | CategoryBehavioralPatterns | CategoryRealTimePatterns | CategoryRealTime