Lazuli
Loading...
Searching...
No Matches
scheduler.c
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-only
3 * This file is part of Lazuli.
4 */
5
14#include <stdint.h>
15
16#include <Lazuli/common.h>
17#include <Lazuli/config.h>
18#include <Lazuli/lazuli.h>
19#include <Lazuli/list.h>
20#include <Lazuli/mutex.h>
21
24#include <Lazuli/sys/clock_24.h>
25#include <Lazuli/sys/compiler.h>
26#include <Lazuli/sys/kernel.h>
27#include <Lazuli/sys/memory.h>
29
34
41
50
59
64
69
74
80static NOINIT Task *idleTask;
81
86 NULL ,
89 0 ,
90 0 ,
91 0
92};
93
99static void
101{
102 for (;;) {
105 }
106 }
107}
108
115static void
117{
118 TaskContextLayout * const contextLayout
120 - sizeof(TaskContextLayout) + 1);
121
122 contextLayout->pc = ReverseBytesOfFunctionPointer(task->entryPoint);
123 contextLayout->terminationCallback =
125
126 task->stackPointer = ALLOW_ARITHM((void*)contextLayout) - 1;
127}
128
139static bool
140PeriodComparer(const Task * const task1, const Task * const task2)
141{
142 return task1->period > task2->period;
143}
144
155static bool
156PriorityComparer(const Task * const task1, const Task * const task2)
157{
158 return task1->priority > task2->priority;
159}
160
174static void
176 Task * const taskToInsert,
177 bool (*compareByProperty)(const Task * const ,
178 const Task * const))
179{
180 Task *task;
181
182 /*
183 * This is commented on purpose.
184 * TODO: Find a neat way to perform the equivalent. This function is static
185 * so we master the parameters that are passed to that function.
186 * Static checking could do the job.
187 *
188 * if (NULL == list || NULL == taskToInsert || NULL == compareByProperty) {
189 * return;
190 * }
191 */
192
193 List_ForEach (list, Task, task, stateQueue) {
194 if (compareByProperty(task, taskToInsert)) {
196 &task->stateQueue,
197 &taskToInsert->stateQueue);
198
199 return;
200 }
201 }
202
203 List_Append(list, &taskToInsert->stateQueue);
204}
205
214 The_readyTasks_array_size_is_wrong);
227static Task*
229{
231
232 for (policy = 0; policy < ELEMENTS_COUNT(readyTasks); ++policy) {
233 const Lz_LinkedListElement * const linkedListElement
234 = List_PickFirst(&readyTasks[policy]);
235
236 if (NULL != linkedListElement) {
237 return CONTAINER_OF(linkedListElement, stateQueue, Task);
238 }
239 }
240
241 return idleTask;
242}
243
249static void
251{
252 Task *loopTask;
253 Lz_LinkedListElement *iterator;
254
255 /* Here we update the time until activation of all cyclic RT tasks */
256 List_ForEach(&readyTasks[CYCLIC_RT], Task, loopTask, stateQueue) {
257 --loopTask->timeUntilActivation;
258
259 if (0 == loopTask->timeUntilActivation) {
260 if (loopTask->timeUntilCompletion > 0) {
261 /* TODO: Missed deadline */
262 } else {
263 loopTask->timeUntilActivation = loopTask->period;
264 }
265 }
266 }
267
268 /* After updating, we check if a cyclic RT task is ready to run */
270 Task,
271 loopTask,
272 stateQueue,
273 iterator) {
274 --loopTask->timeUntilActivation;
275
276 if (0 == loopTask->timeUntilActivation) {
277 iterator = List_Remove(&waitingActivationTasks, &loopTask->stateQueue);
279
280 loopTask->timeUntilActivation = loopTask->period;
281 loopTask->timeUntilCompletion = loopTask->completion;
282 }
283 }
284}
285
291static void
293{
294 Task *task;
295 Lz_LinkedListElement *iterator;
296
297 List_RemovableForEach(&waitingTimerTasks, Task, task, stateQueue, iterator) {
299
300 if (0 == task->timeUntilTimerExpiration) {
301 iterator = List_Remove(&waitingTimerTasks, &task->stateQueue);
303 }
304 }
305}
306
312static void
325
331static void
333{
334 bool setCurrentTaskReady = false;
335
336 if (WAIT_INTERRUPT == message) {
337 const uint8_t interruptCode =
339
340 /*
341 * If the requested interrupt code is not an acceptable value, we abort the
342 * task.
343 */
345 (interruptCode > INT_LAST_ENTRY)) {
347
348 return;
349 }
350
351 List_Prepend(&waitingInterruptsTasks[interruptCode],
353 } else if (WAIT_SOFTWARE_TIMER == message) {
357 setCurrentTaskReady = true;
358 } else {
360 }
361 } else if (LZ_CONFIG_MODULE_MUTEX_USED && (WAIT_MUTEX == message)) {
364 } else {
365 setCurrentTaskReady = true;
366 }
367
368 if (setCurrentTaskReady) {
372 }
373}
374
386static void
388{
389 /*
390 * We call this function before adding new tasks waiting for a software timer
391 * in order to avoid decrementing the expiration counter immediately after
392 * adding the task to the corresponding waiting list.
393 */
395
396 if (currentTask != idleTask) {
397 /*
398 * currentTask->taskToSchedulerMessage is declared 'volatile'. However, we
399 * are here in the scheduler, which is not interruptible. We can then cache
400 * the message value in a variable to avoid reading it from memory each time
401 * we access it.
402 */
405
406 if (ABORT_TASK == message) {
408 } else if (TERMINATE_TASK == message) {
410 } else {
411 /* Array of function pointers, built on the stack */
412 void
413 (* const jumpToManager[LZ_SCHEDULING_POLICY_MAX + 1])
415 {
418 };
419
420 jumpToManager[currentTask->schedulingPolicy](message);
421 }
422 }
423
425
427
429}
430
442static Task *
443CallbackRegisterUserTask(const Lz_TaskConfiguration * const taskConfiguration)
444{
445 Task *newTask;
446 /*
447 * Jump table to the appropriate comparer, depending of the desired
448 * scheduling policy.
449 */
450 bool (* const comparers[LZ_SCHEDULING_POLICY_MAX + 1]) (const Task * const,
451 const Task * const) =
452 {
455 };
456
457 if (taskConfiguration->schedulingPolicy > LZ_SCHEDULING_POLICY_MAX) {
458 return NULL;
459 }
460
461 if (CYCLIC_RT == taskConfiguration->schedulingPolicy &&
462 (0 == taskConfiguration->period || 0 == taskConfiguration->completion)) {
463 return NULL;
464 }
465
466 newTask = KIncrementalMalloc(sizeof(Task));
467 if (NULL == newTask) {
468 return NULL;
469 }
470
471 newTask->priority = taskConfiguration->priority;
472 newTask->period = taskConfiguration->period;
473 newTask->completion = taskConfiguration->completion;
474
475 newTask->timeUntilActivation = newTask->period;
476 newTask->timeUntilCompletion = newTask->completion;
477
479
481 newTask,
482 comparers[taskConfiguration->schedulingPolicy]);
483
484 return newTask;
485}
486
493static Task *
495{
497 if (NULL == idleTask) {
498 return NULL;
499 }
500
501 return idleTask;
502}
503
520static bool
521RegisterTask(void (* const taskEntryPoint)(void),
522 Lz_TaskConfiguration * taskConfiguration,
523 const bool isIdleTask)
524{
525 Lz_TaskConfiguration defaultConfiguration;
526 Task *newTask;
527 void *taskStack;
528 size_t desiredStackSize;
529
530 if (NULL == taskConfiguration) {
532 &defaultConfiguration,
533 sizeof(Lz_TaskConfiguration));
534 taskConfiguration = &defaultConfiguration;
535 } else if (taskConfiguration->stackSize < LZ_CONFIG_DEFAULT_TASK_STACK_SIZE) {
536 taskConfiguration->stackSize = LZ_CONFIG_DEFAULT_TASK_STACK_SIZE;
537 }
538
539 if (isIdleTask) {
540 newTask = CallbackRegisterIdleTask();
541 } else {
542 newTask = CallbackRegisterUserTask(taskConfiguration);
543 }
544
545 if (NULL == newTask) {
546 return false;
547 }
548
549 desiredStackSize = taskConfiguration->stackSize
550 /* We add enough space to contain the context of a task on the stack */
551 + sizeof(TaskContextLayout)
552 /* Plus 1 call to save_context_on_stack (in startup.S) */
553 + sizeof(void (*)(void));
554
555 taskStack = KIncrementalMalloc(desiredStackSize);
556 if (NULL == taskStack) {
557 return false;
558 }
559
560 newTask->schedulingPolicy = taskConfiguration->schedulingPolicy;
561 newTask->name = taskConfiguration->name;
562 newTask->entryPoint = taskEntryPoint;
563 newTask->stackSize = desiredStackSize;
564 newTask->stackOrigin = ALLOW_ARITHM(taskStack) + desiredStackSize - 1;
565 newTask->stackPointer = newTask->stackOrigin;
566 newTask->timeUntilTimerExpiration = 0;
568
569 PrepareTaskContext(newTask);
570
571 return true;
572}
573
581static bool
583{
584 Lz_TaskConfiguration taskConfiguration;
585
586 Lz_TaskConfiguration_Init(&taskConfiguration);
587
588 taskConfiguration.stackSize = LZ_CONFIG_IDLE_TASK_STACK_SIZE;
589
591 taskConfiguration.name = LZ_CONFIG_IDLE_TASK_NAME;
592 }
593
594 return RegisterTask(IdleTask, &taskConfiguration, true);
595}
596
613void
614(*ReverseBytesOfFunctionPointer(void (* const pointer)(void)))(void)
615{
616 const uint8_t maxIndex = sizeof(pointer) - 1;
617 const uint8_t * const oldPointerPointer = (const uint8_t * const)&pointer;
618 void (*newPointer)(void);
619 uint8_t * const newPointerPointer = (uint8_t * const)&newPointer;
620 uint8_t i;
621
622 for (i = 0; i <= maxIndex; ++i) {
623 newPointerPointer[maxIndex - i] = oldPointerPointer[i];
624 }
625
626 return newPointer;
627}
628
631void
633{
634 size_t i;
635 const Lz_LinkedList linkedListInit = LINKED_LIST_INIT;
636
638
639 for (i = 0; i < ELEMENTS_COUNT(readyTasks); ++i) {
640 Memory_Copy(&linkedListInit, &readyTasks[i], sizeof(linkedListInit));
641 }
642
643 for (i = 0; i < ELEMENTS_COUNT(waitingInterruptsTasks); ++i) {
644 Memory_Copy(&linkedListInit,
646 sizeof(linkedListInit));
647 }
648}
649
650void
657
658/*
659 * This function is executed on the current task's stack. So go easy with stack
660 * usage.
661 */
662void
664{
665 Task *loopTask;
666 Lz_LinkedListElement *iterator;
667
669 if (interruptCode > INT_LAST_ENTRY) {
670 Kernel_Panic();
671 }
672 }
673
675 Task,
676 loopTask,
677 stateQueue,
678 iterator) {
679 iterator = List_Remove(&waitingInterruptsTasks[interruptCode],
680 &loopTask->stateQueue);
682 }
683}
684
685void
698
699void
701{
702 Task *loopTask;
703 Lz_LinkedListElement *iterator;
704
705 /* TODO: Ugly */
707 UNUSED(mutex);
708 UNUSED(loopTask);
709 UNUSED(iterator);
710
711 return;
712 }
713
715 Task,
716 loopTask,
717 stateQueue,
718 iterator) {
719 iterator = List_Remove(&mutex->waitingTasks,
720 &loopTask->stateQueue);
722 }
723}
724
725Task*
727{
728 return currentTask;
729}
730
731void
733{
734 /*
735 * We use this do-while loop because the task can be woken up by any interrupt
736 * source. In the case of standard interrupts (i.e. not a clock tick)
737 * the task needs to sleep again after the interruption has been managed.
738 * In other words, currentTask->taskToSchedulerMessage will be equal to
739 * NO_MESSAGE only if the task's time slice has finished.
740 */
741 do {
744}
745
751void
753{
754 if (NULL == taskConfiguration) {
755 return;
756 }
757
759 taskConfiguration,
760 sizeof(Lz_TaskConfiguration));
761}
762
763bool
764Lz_RegisterTask(void (* const taskEntryPoint)(void),
765 Lz_TaskConfiguration * taskConfiguration)
766{
767 return RegisterTask(taskEntryPoint, taskConfiguration, false);
768}
769
770void
783
784const char *
786{
787 return currentTask->name;
788}
789
790void
797
798void
800{
801 /* TODO: Check if the calling task's scheduling policy is PRIORITY_RT */
802
805
807}
808
809void
811{
812 /* TODO: Check if the calling task's scheduling policy is PRIORITY_RT */
813
816
818}
819
820void
827
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
Definition stdint.h:89
void Arch_CpuSleep(void)
Put the CPU to sleep according to the sleep settings.
Definition arch.c:60
Architecture Abstraction API.
void Arch_LoadFromProgmem(const void *source, void *destination, const size_t size)
Copy bytes from program memory to RAM.
void Arch_RestoreContextAndReturnFromInterrupt(void *stackPointer)
Restore the context of a previously saved task, and run it by returning from interrupt.
void Clock24_Increment(void)
Increment the 24-Hour clock, taking into the account the resolution of the system clock.
Definition clock_24.c:97
Basic type definitions and useful macros.
#define NULL
NULL pointer.
Definition common.h:70
uint8_t bool
Boolean type.
Definition common.h:80
#define STATIC_ASSERT(C, M)
Perform an assertion at compile time.
Definition common.h:65
#define UNUSED(X)
Tell the compiler that the variable X is left unused.
Definition common.h:53
#define CONTAINER_OF(P, M, T)
Get a pointer to the structure T containing the member M pointed by P.
Definition common.h:251
#define ELEMENTS_COUNT(X)
Get the number of elements in a statically initialized array.
Definition common.h:266
#define ALLOW_ARITHM(X)
Allow arithmetic on a void pointer.
Definition common.h:118
Macro aliases on compiler facilities.
Include appropriate config file.
const bool LZ_CONFIG_CHECK_INTERRUPT_CODE_OVER_LAST_ENTRY
When 1, check if the interrupt code sent by the ASM interrupt handler to the base scheduler interrupt...
const bool LZ_CONFIG_ON_IDLE_SLEEP
When 1, put the CPU to sleep when it's idle.
const bool LZ_CONFIG_IDLE_TASK_HAS_NAME
Configure if the idle task must have a name.
const bool LZ_CONFIG_MODULE_CLOCK_24_USED
Use module "clock_24": Implement a 24-Hour clock in the kernel.
const bool LZ_CONFIG_MODULE_MUTEX_USED
Use module "mutex": Mutexes implementation.
const size_t LZ_CONFIG_DEFAULT_TASK_STACK_SIZE
Default stack size in bytes for a new task.
const size_t LZ_CONFIG_IDLE_TASK_STACK_SIZE
The stack size in bytes of the scheduler idle task.
const char *const LZ_CONFIG_IDLE_TASK_NAME
The name of the idle task.
Interrupt codes of ATmega328P.
#define INT_LAST_ENTRY
Alias for the last code used.
Definition interrupts.h:153
#define INT_TOTAL
Total interrupt codes used.
Definition interrupts.h:158
void Kernel_Panic(void)
Kernel panic.
Definition kernel.c:84
Kernel symbols definition.
The public API of the Lazuli kernel.
#define CYCLIC_RT
Cyclic real-time scheduling.
Definition lazuli.h:51
#define LZ_SCHEDULING_POLICY_MAX
Represents the maximum value currently defined for a lz_scheduling_policy_t.
Definition lazuli.h:63
uint8_t lz_scheduling_policy_t
Represents the type used for scheduling policies of a Lazuli user task.
Definition lazuli.h:41
#define PRIORITY_RT
Priority time sliced real-time scheduling.
Definition lazuli.h:58
uint16_t lz_u_resolution_unit_t
Represents the type used for the system clock resolution unit, as an unsigned integer.
Definition lazuli.h:36
void List_Append(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the last element of an existing Lz_LinkedList.
Definition list.c:22
Lz_LinkedListElement * List_PickFirst(Lz_LinkedList *const linkedList)
Return the first element of an existing linked list.
Definition list.c:98
Lz_LinkedListElement * List_Remove(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const itemToRemove)
Remove an element from an Lz_LinkedList.
Definition list.c:197
void List_Prepend(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the first element of an existing Lz_LinkedList.
Definition list.c:46
void List_InitLinkedListElement(Lz_LinkedListElement *const item)
Initialize an Lz_LinkedListElement.
Definition list.c:266
void List_InsertBefore(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const listItem, Lz_LinkedListElement *const itemToInsert)
Insert an element before another in a Lz_LinkedList.
Definition list.c:173
Doubly linked lists interface.
#define List_ForEach(LINKEDLIST, TYPE, ITEM, MEMBER)
Run through an Lz_LinkedList like a for loop.
Definition list.h:178
#define List_RemovableForEach(LINKEDLIST, TYPE, ITEM, MEMBER, ITERATOR)
Run through an Lz_LinkedList like a for loop, with the ability of removing elements from the list whi...
Definition list.h:222
#define LINKED_LIST_INIT
Define the initialization value for the type Lz_LinkedList.
Definition list.h:47
void * KIncrementalMalloc(const size_t size)
Allocate memory for kernel objects using incremental method.
Definition memory.c:67
void Memory_Copy(const void *source, void *destination, const size_t size)
Copy bytes from one location to another in main memory.
Definition memory.c:73
Memory management API.
Mutexes interface.
void Lz_TaskConfiguration_Init(Lz_TaskConfiguration *const taskConfiguration)
Initialize an Lz_TaskConfiguration with default values for all parameters.
Definition scheduler.c:752
static void UpdateTasksWaitingSoftwareTimer(void)
Update all tasks waiting for the expiration of a software timer.
Definition scheduler.c:292
void Scheduler_HandleInterrupt(const uint8_t interruptCode)
This function is called by arch-specific interrupt handling routine.
Definition scheduler.c:663
Task * Scheduler_GetCurrentTask(void)
Get a pointer to the current running task.
Definition scheduler.c:726
static Lz_LinkedList waitingInterruptsTasks[INT_TOTAL]
The table of waiting queues for interrupts.
Definition scheduler.c:58
void Lz_WaitTimer(lz_u_resolution_unit_t units)
Set the calling task to wait for the specified number of time resolution units (time slices),...
Definition scheduler.c:810
static Task * currentTask
A pointer to the current running task.
Definition scheduler.c:33
void Lz_Task_WaitInterrupt(uint8_t interruptCode)
Wait for a specific interrupt to occur.
Definition scheduler.c:799
static void Schedule(void)
Elect the new current task.
Definition scheduler.c:387
void Lz_Task_WaitActivation(void)
Set the calling task to wait for its next activation.
Definition scheduler.c:791
const char * Lz_Task_GetName(void)
Get the name of the calling task.
Definition scheduler.c:785
static Lz_LinkedList readyTasks[LZ_SCHEDULING_POLICY_MAX+1]
The queues of ready tasks for each scheduling policy.
Definition scheduler.c:40
static bool RegisterTask(void(*const taskEntryPoint)(void), Lz_TaskConfiguration *taskConfiguration, const bool isIdleTask)
Register a new task.
Definition scheduler.c:521
void Scheduler_AbortTask(void)
Abort the current running task.
Definition scheduler.c:651
static bool PeriodComparer(const Task *const task1, const Task *const task2)
Compare the "period" property of 2 tasks.
Definition scheduler.c:140
static Lz_LinkedList abortedTasks
The queue of aborted tasks.
Definition scheduler.c:73
static bool PriorityComparer(const Task *const task1, const Task *const task2)
Compare the "priority" property of 2 tasks.
Definition scheduler.c:156
static Lz_LinkedList waitingActivationTasks
The queue of tasks waiting activation.
Definition scheduler.c:49
void Lz_Task_Terminate(void)
Terminate the calling task.
Definition scheduler.c:821
static Task * idleTask
The idle task.
Definition scheduler.c:80
static Task * CallbackRegisterIdleTask(void)
Callback of SchedulerOperations.registerTask() for registering the scheduler idle task.
Definition scheduler.c:494
static bool RegisterIdleTask(void)
Register the idle task.
Definition scheduler.c:582
static Task * CallbackRegisterUserTask(const Lz_TaskConfiguration *const taskConfiguration)
Callback of SchedulerOperations.registerTask() for registering a user task.
Definition scheduler.c:443
static Lz_LinkedList waitingTimerTasks
The queue of tasks waiting for their software timer to reach expiration.
Definition scheduler.c:63
void Scheduler_SleepUntilEndOfTimeSlice(void)
Put the current task to sleep until the end of its time slice.
Definition scheduler.c:732
static Lz_LinkedList terminatedTasks
The queue of terminated tasks.
Definition scheduler.c:68
void Lz_Run(void)
Run the scheduler.
Definition scheduler.c:771
static const Lz_TaskConfiguration DefaultTaskConfiguration
Contains default values for Lz_TaskConfiguration.
Definition scheduler.c:85
static void IdleTask(void)
The scheduler idle task.
Definition scheduler.c:100
void Scheduler_Init(void)
Initialize the scheduler prior to running it.
Definition scheduler.c:632
static void ManagePriorityRealTimeTask(const lz_task_to_scheduler_message_t message)
Manage priority real-time tasks.
Definition scheduler.c:332
bool Lz_RegisterTask(void(*const taskEntryPoint)(void), Lz_TaskConfiguration *taskConfiguration)
Register a new task.
Definition scheduler.c:764
static Task * PickTaskToRun(void)
Pick the task ready to run with the highest priority.
Definition scheduler.c:228
static void ManageCyclicRealTimeTask(const lz_task_to_scheduler_message_t message)
Manage cyclic real-time tasks.
Definition scheduler.c:313
static void InsertTaskByPriority(Lz_LinkedList *const list, Task *const taskToInsert, bool(*compareByProperty)(const Task *const, const Task *const))
Insert a task in a list, keeping priorities ordered.
Definition scheduler.c:175
void Scheduler_HandleClockTick(void *const sp)
This function is called when a clock tick occurred, catch by the interrupt handler.
Definition scheduler.c:686
static void PrepareTaskContext(Task *const task)
Prepare the first context of the task so it will be ready when switching context for the first time (...
Definition scheduler.c:116
void Scheduler_WakeupTasksWaitingMutex(Lz_Mutex *const mutex)
Wake up all tasks waiting for a mutex.
Definition scheduler.c:700
static void UpdateCyclicRealTimeTasks(void)
Update all registered cyclic RT tasks.
Definition scheduler.c:250
Lazuli scheduler interface.
void(*)(void) ReverseBytesOfFunctionPointer(void(*const pointer)(void))
Reverse the bytes of a function pointer.
Definition scheduler.h:35
Represents the main container for doubly linked elements.
Definition list.h:36
Represents a mutex.
Definition mutex.h:28
Lz_LinkedList waitingTasks
The list of tasks waiting for that mutex.
Definition mutex.h:30
Represents the configuration of a task.
Definition lazuli.h:68
lz_scheduling_policy_t schedulingPolicy
The scheduling policy of the task.
Definition lazuli.h:84
char const * name
A pointer to an allocated const string containing the name to give to the task.
Definition lazuli.h:74
lz_u_resolution_unit_t completion
The completion time (C) of the task (worst case execution time).
Definition lazuli.h:105
lz_task_priority_t priority
The priority of task.
Definition lazuli.h:90
size_t stackSize
The size of the stack needed by the task.
Definition lazuli.h:79
lz_u_resolution_unit_t period
The period (T) of the task.
Definition lazuli.h:97
Represents the layout of the stack when saving the context of a task.
Definition task.h:209
volatile FuncVoidVoid pc
Program counter for the task.
Definition task.h:310
volatile FuncVoidVoid terminationCallback
Callback to the scheduler to manage task termination.
Definition task.h:318
Represents a task.
Definition task.h:82
const char * name
The name of the task.
Definition task.h:88
size_t stackSize
The stack size of the task.
Definition task.h:115
void * taskToSchedulerMessageParameter
A parameter that can accompany a taskToSchedulerMessage.
Definition task.h:187
lz_u_resolution_unit_t period
The period (T) of the task, expressed as an integer number of time units.
Definition task.h:136
lz_scheduling_policy_t schedulingPolicy
The scheduling policy.
Definition task.h:125
lz_u_resolution_unit_t timeUntilTimerExpiration
The number of time units until the software timer expires for the task.
Definition task.h:165
void * stackPointer
The saved stack pointer of the task.
Definition task.h:120
volatile lz_task_to_scheduler_message_t taskToSchedulerMessage
The message the task has to pass to the scheduler for the next scheduling operation (i....
Definition task.h:180
lz_u_resolution_unit_t completion
The completion time (C) of the task (worst case execution time), expressed as an integer number of ti...
Definition task.h:143
void(* entryPoint)(void)
Entry point of execution of the task.
Definition task.h:95
lz_task_priority_t priority
The task priority.
Definition task.h:160
void * stackOrigin
The bottom of the allocated stack for the task.
Definition task.h:108
Lz_LinkedListElement stateQueue
The scheduling queue on which the task is stored.
Definition task.h:130
lz_u_resolution_unit_t timeUntilCompletion
The number of time units until the task will complete its execution.
Definition task.h:149
lz_u_resolution_unit_t timeUntilActivation
The number of time units until the task will be activated.
Definition task.h:155
Represents an element of a doubly linked list.
Definition list.h:25
24-Hour clock kernel interface.
#define WAIT_SOFTWARE_TIMER
Set the task to wait for the specified number of time resolution units, using the software timer.
Definition task.h:71
#define TERMINATE_TASK
Terminate the task.
Definition task.h:57
#define WAIT_INTERRUPT
Set the task to wait for an interrupt.
Definition task.h:52
#define NO_MESSAGE
No message has to be passed to the scheduler.
Definition task.h:40
#define WAIT_ACTIVATION
Set the task to wait for its next activation.
Definition task.h:46
#define ABORT_TASK
Abort the curent running task.
Definition task.h:77
u_read_write_atomic_t lz_task_to_scheduler_message_t
Defines the type used to contain a message that a Task can pass to the scheduler after its time slice...
Definition task.h:35
#define WAIT_MUTEX
Wait for a mutex to be unlocked.
Definition task.h:63
void Arch_InitSystemTimer(void)
Initialize the system timer.
void Arch_StartSystemTimer(void)
Start the system timer.