CHAPTER 16 SCHEDULING FUNCTION
The scheduling functions provided by the RI600PX consist of functions manage/decide the order in which tasks are executed by monitoring the transition states of dynamically changing tasks, so that the CPU use right is given to the optimum task.
Since interrupt handler, cyclic handlers, alarm handlers and access exception handler have higher precedence than the scheduler, no tasks and no task exception handling routines are executed while these handlers are executing. ( Refer to "16.7 Task Scheduling in Non-Tasks").
The precedence of a cyclic handler and alarm handler is the same as the interrupt handler which interrupt level is same as the base clock timer interrupt.
The RI600PX employs the Event-driven system in which the scheduler is activated when an event (trigger) occurs.
Under the event-driven system of the RI600PX, the scheduler is activated upon occurrence of the events listed below and dispatch processing (task scheduling processing) is executed.
As task scheduling methods, the RI600PX employs the Priority level method, which uses the priority level defined for each task, and the FCFS method, which uses the time elapsed from the point when a task becomes target to RI600PX scheduling.
A task with the highest current priority is selected from among all the tasks that have entered an executable state (RUNNING state or READY state), and given the CPU use right.
When two or more "task with the highest priority level" exist, the scheduling target task can not be decided only by the Priority level method. In this case, the RI600PX decides the scheduling target task by first come first served (FCFS) method. Concretely, the task that enters to executable state (READY state) earliest among them, and given the CPU use right.
The ready queue is a hash table that uses priority as the key, and tasks that have entered an executable state (READY state or RUNNING state) are queued in FIFO order. Therefore, the scheduler realizes the RI600PX's scheduling method (priority level or FCFS) by executing task detection processing from the highest priority level of the ready queue upon activation, and upon detection of queued tasks, giving the CPU use right to the first task of the proper priority level.
- Create ready queue
In the RI600PX, the method of creating a ready queue is limited to "static creation".
Ready queues therefore cannot be created dynamically using a method such as issuing a service call from a processing program.
Static ready queue creation means defining of Maximum task priority (priority) in System Information (system) in the system configuration file.
In the RI600PX, the method of creating a ready queue is limited to "static creation".
Ready queues therefore cannot be created dynamically using a method such as issuing a service call from a processing program.
Static ready queue creation means defining of Maximum task priority (priority) in System Information (system) in the system configuration file.
The RI600PX provides the scheduling lock function for manipulating the scheduler status explicitly from the processing program and disabling/enabling dispatch processing.
When there is no RUNNING or READY task, the RI600PX enters an endless loop and waits for interrupts.
If processing of non-tasks starts, any tasks will not be performed until non-task processing is completed, since the precedence of non-task (interrupt handler, cyclic handler, alarm handler and access exception handler) is higher than task as shown in "16.2 Processing Unit and Precedence".
The following shows a example when a service call accompanying dispatch processing is issued in non-tasks. In this example, when the interrupt handler issues iwup_tsk, the Task A whose priority is higher than the task B is released from the WAITING state, but processing of the interrupt handler is continued at this time, without performing the task A yet. When processing of the interrupt handler is completed, the scheduler is started, and as a result, the task A is performed.