#include "opale_internal.h"
Include dependency graph for opale_core.c:
Go to the source code of this file.
Functions | ||||||
void | op_KernelInit (register t_op_BUFFER *buffer asm(" "), register unsigned char rotationMask asm("Ð")) | |||||
void | PerformDelay (void) | |||||
unsigned char | rotate (unsigned char t, register unsigned char n asm("Ò")) | |||||
void | Scheduler (void) | |||||
Variables | ||||||
t_TASK | idleTask | |||||
char * | idleTaskStack | |||||
unsigned char * | indexToLowestSettedBit | |||||
unsigned short | kernelStarted | |||||
unsigned short | void PerformDelay | ( | void | ) |
Advance each sleeping task's counter and wake any task whose counter reaches zero. References addTaskToTable(), t_TASK::ident, idleTask, t_TASK::nextSleeping, t_TASK::prevSleeping, readyTasks, and t_TASK::tickDelay. Here is the call graph for this function: ![]() |
|
Definition at line 129 of file opale_core.c. References _X_. Referenced by Scheduler(). |
|
The scheduler is used to find the task that is to be run
Find the task with the highest priority ready to run, and make switch the context to run it if it isn't already running.
Let's see the tools we'll use to do the job ...
indexToLowestSettedBitIndex : static const unsigned char indexToLowestUnsettedBitIndex [ 16 ] = { 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, It works for a 4-bits index, since we have 16 tasks max. The first 8 values (index 0-7) are never used since there's always alt least the idle task runnig.
ex :
readyTasksTable : <-------- X ----------- 7 6 5 4 3 2 1 0 | -------------------- | It is a table of 4 bytes, but we use ontly the lowest 4 bits of those. | . . . . | 3 2 1 0 | | 0 I draw on here the representation of the array with the bits correspounding | . . . . | 7 6 5 4 | Y 1 to the tasks' priorities. When a bit is set, the task is ready and pending. | . . . . | B A 9 8 | | 2 The 0 is the highest priority. | . . . . | F E D C | V 3 The table is never empty since the 15th task (idle) is always runnig ! readyRowIndex :
| . . . . | 3 2 1 0 |
The bit n°x of readyTasksRowIndex is set when the row n°x of readyTasksTable is not 0.
priority :
<-Y-> <-X->
A task priority is unique, and goes from 0 (highest) to 15 (lowest)
bits 0-1 are the X index in the ready tasks table.
It is just because of how you write it in binary, and because the ready tasks table is 4*4.
Now it becomes easy to get the highest priority task :
indexToLowestSettedBitIndex[ readyTasksRowIndex ] gives y (the lowest index of a row containing pending tasks)
Here we have the priority / ident of the task:
ident = ( y << 2 ) x References ContextSwitch(), currentTask, t_TASK::ident, indexToLowestSettedBit, indexToSettedBit, MASK_X, MASK_Y, readyTasks, rotate(), roundRobin, t_TASK_BLOCK::rowIndex, runningTasks, and t_TASK_BLOCK::tasksTable. Here is the call graph for this function: ![]() |
|
Task Control Block for the idle task. Definition at line 44 of file opale_core.c. Referenced by op_KernelInit(), op_TaskWaitForTicks(), and PerformDelay(). |
|
Pointer to the idle task's stack. Its depths is IDLE_TASK_STACK_SIZE bytes. Definition at line 46 of file opale_core.c. Referenced by op_KernelInit(). |
|
indexToLowestSettedBit is a pointer to a table used to get the index of the lowest weighted setted bit of a number. Given the number, the value at indexToLowestSettedBit[ number ] is the index of the wanted bit.
Here is what would the table looks like fo 64 tasks: indexToLowestSettedBit[ TO_LOWEST_SETTED_BIT_TABLE_SIZE ] = { 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; Referenced by MakeTaskReady(), op_KernelInit(), and Scheduler(). |
|
Definition at line 41 of file opale_core.c. Referenced by op_KernelInit(). |
|
Definition at line 39 of file opale_core.c. Referenced by op_KernelInit(). |
|
Definition at line 40 of file opale_core.c. Referenced by op_KernelInit(). |
|
pointer to the task block used for general purpose scheduling. Definition at line 53 of file opale_core.c. Referenced by MakeTaskReady(), op_KernelInit(), op_TaskStart(), op_TaskStop(), op_TaskWaitForTicks(), PerformDelay(), Scheduler(), and WaitForEvent(). |
|
Pointer to the task block used for round-robin scheduling. Definition at line 51 of file opale_core.c. Referenced by op_KernelInit(), and Scheduler(). |
|
Pointer to the array of running tasks. Definition at line 49 of file opale_core.c. Referenced by op_KernelInit(), op_TaskStart(), op_TaskStop(), and Scheduler(). |