Global

group Global_scheduler

scheduler globals

lorem

Macros

group Macros_scheduler_h

Variables

group Variables_scheduler_h

API’s

group Apis_scheduler_h

Getters

group Getters_scheduler_h

Functions

CosmOS_ScheduleTableConfigurationType *scheduler_getSchedulerScheduleTable(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler scheduleTable pointer.

Parameters

scheduler[in] configuration pointer

Returns

CosmOS_ScheduleTableConfigurationType *

BitWidthType scheduler_getSchedulerHyperTick(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler hyperTick.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerPreemptTick(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler preemptTick.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerScheduleTableElementsNum(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler scheduleTableElementsNum.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerThreadListElementsNum(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler threadListElementsNum.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerLastToFirstTaskTicks(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler lastToFirstTaskTicks.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerSyncTicks(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler syncTicks.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerFirstSyncTaskStartTick(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler firstSyncTaskStartTick.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerMaxTimerTick(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler maxTimerTick.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerTimerTickCount(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler timerTickCount.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

CosmOS_TaskConfigurationType *scheduler_getSchedulerIdleTask(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler idleTask.

Parameters

scheduler[in] configuration pointer

Returns

CosmOS_TaskConfigurationType *

CosmOS_AlarmConfigurationType *scheduler_getAlarmCfgs(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler alarmCfgs.

Parameters

scheduler[in] configuration pointer

Returns

CosmOS_AlarmConfigurationType

CosmOS_AlarmConfigurationType *scheduler_getAlarmCfg(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType alarmId)
BitWidthType scheduler_getSchedulerCurrentTick(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler currentTick.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerPriorTickStep(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler priorTickStep.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerScheduleTableIterator(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler scheduleTableIterator.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerThreadListIterator(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler threadListIterator.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

CosmOS_SchedulerStateType scheduler_getSchedulerState(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler schedulerState.

Parameters

scheduler[in] configuration pointer

Returns

CosmOS_SchedulerStateType

BitWidthType scheduler_getSchedulerNextSyncTick(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler nextSyncTick.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

CosmOS_BooleanType scheduler_getSchedulerSyncInitState(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler syncInitState.

Parameters

scheduler[in] configuration pointer

Returns

CosmOS_BooleanType

CosmOS_RescheduleTriggerStateType scheduler_getSchedulerRescheduleTriggerState(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler rescheduleTriggerState.

Parameters

scheduler[in] configuration pointer

Returns

CosmOS_RescheduleTriggerStateType

BitWidthType scheduler_getSchedulerTimerOffset(CosmOS_SchedulerConfigurationType *scheduler)

Get scheduler timerOffset.

Parameters

scheduler[in] configuration pointer

Returns

BitWidthType

BitWidthType scheduler_getSchedulerScheduleTableStartTick(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType scheduleTableIterator)

Get scheduler scheduleTable element startTick.

Parameters
  • scheduler[in] configuration pointer

  • scheduleTableIterator[in] iterator pointing to specific task variable in the schedule table

Returns

BitWidthType

CosmOS_TaskConfigurationType *scheduler_getSchedulerScheduleTableTaskVar(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType scheduleTableIterator)

Get scheduler scheduleTable element taskVar.

Parameters
  • scheduler[in] configuration pointer

  • scheduleTableIterator[in] iterator pointing to specific task variable in the schedule table

Returns

CosmOS_TaskConfigurationType *

CosmOS_ThreadConfigurationType *scheduler_getSchedulerThreadListThreadVar(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType threadListIterator)

Get scheduler threadList element threadVar.

Parameters
  • scheduler[in] configuration pointer

  • threadListIterator[in] iterator pointing to specific thread configuration in the thread list

Returns

CosmOS_ThreadConfigurationType *

Setters

group Setters_scheduler_h

Functions

void scheduler_setSchedulerCurrentTick(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType currentTickParam)

Set scheduler currentTick. This function cannot be called from the unprivileged context directly.

Parameters
  • scheduler[out] configuration pointer

  • currentTickParam[in] current tick to be set

Returns

none

void scheduler_setSchedulerPriorTickStep(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType priorTickStepParam)

Set scheduler priorTickStep. This function cannot be called from the unprivileged context directly.

Parameters
  • scheduler[out] configuration pointer

  • priorTickStepParam[in] prior tick step to be set

Returns

none

void scheduler_setSchedulerScheduleTableIterator(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType scheduleTableIteratorParam)

Set scheduler scheduleTableIterator. This function cannot be called from the unprivileged context directly.

Parameters
  • scheduler[out] configuration pointer

  • scheduleTableIteratorParam[in] schedule table iterator to be set

Returns

none

void scheduler_setSchedulerThreadListIterator(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType threadListIteratorParam)

Set scheduler threadListIterator. This function cannot be called from the unprivileged context directly.

Parameters
  • scheduler[out] configuration pointer

  • threadListIteratorParam[in] thread list iterator to be set

Returns

none

void scheduler_setSchedulerState(CosmOS_SchedulerConfigurationType *scheduler, CosmOS_SchedulerStateType schedulerStateParam)

Set scheduler schedulerState. This function cannot be called from the unprivileged context directly.

Parameters
  • scheduler[out] configuration pointer

  • schedulerStateParam[in] state of the scheduler to be set

Returns

none

void scheduler_setSchedulerNextSyncTick(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType paramNextSyncTick)
void scheduler_setSchedulerSyncInitState(CosmOS_SchedulerConfigurationType *scheduler, CosmOS_BooleanType paramSyncInitState)
void scheduler_setSchedulerRescheduleTriggerState(CosmOS_SchedulerConfigurationType *scheduler, CosmOS_RescheduleTriggerStateType paramRescheduleTriggerState)
void scheduler_setSchedulerTimerOffset(CosmOS_SchedulerConfigurationType *scheduler, BitWidthType paramTimerOffset)

General

group General_scheduler_h

Functions

void scheduler_updateAlarms(CosmOS_CoreConfigurationType *core, BitWidthType priorTickStep)

Update alarms. This function cannot be called from the unprivileged context directly.

The implementation contains obtaining of the alarms number used inside the for loop that iterates over all alarm possible identifiers and get based on them alarm variable by calling scheduler_getAlarmCfg function. Then the alarm variable is used in the alarm_getAlarmState function to get alarm state. The alarm state is used in the if condition that checks if the alarm state is ALARM_STATE_ENUM__ACTIVATED which means the alarm internal timer needs to be updated, otherwise the alarm is ignored. The alarm is updated in the sequence where its tick count is obtained by function alarm_getAlarmTickCount and compared in the if condition to the prior tick step. If the prior tick step is bigger or equal to the tick count it means that alarm expires as the decrementing prior tick step would lead to zero or negative alarms timer value, therefore the alarm_expire function is called. Otherwise the tick count is decremented by the prior tick step and stored back to the alarm variable by calling alarm_setAlarmTickCount function.

Parameters
  • core[in] configuration pointer

  • priorTickStep[in] prior tick step of the scheduler

Returns

none

void scheduler_classicScheduling(CosmOS_SchedulerConfigurationType *schedulerVar, CosmOS_SchedulableConfigurationType **schedulableCfg, StackPointerType *stackPointerRetVal, BitWidthType *timerTicks, BitWidthType startTick, BitWidthType currentTick)
void scheduler_timerISRCallback(void)

System timer callback function. This function cannot be called from the unprivileged context directly. DEMO.

The implementation contains obtaining of the core configuration by calling function core_getCoreCfg. The core configuration is then used to get the scheduler variable for the current core. After this point the reschedule state of the scheduler is checked in the if condition. If the reschedule trigger is equal to the RESCHEDULE_TRIGGER_STATE_ENUM__TIMER the scheduling algorithm was not finished in the required time (preempt tick) and an error reaction is triggered. Otherwise the scheduler state is checked in the if condition. If the scheduler state is equal to the SCHEDULER_STATE_ENUM__TASK_EXECUTED_IN_WCET_CHECK, the schedulableState is obtained from the schedulable in execution for the current core configuration and check if it is equal to SCHEDULABLE_STATE_ENUM__EXECUTED. If not an error reaction is triggered. Otherwise the reschedule trigger state is set to RESCHEDULE_TRIGGER_STATE_ENUM__TIMER, timer is set to the preempt period and timer offset is saved to by calling function CILsysTimer_setTicksSaveOffset and scheduler state is set to the SCHEDULER_STATE_ENUM__WAITING_FOR_START_TIME. After this point the scheduling algorithm is triggered by calling CILinterrupt_contextSwitchRoutineTrigger function.

Parameters

none

Returns

none

void scheduler_start(void)

Start of scheduler. This function cannot be called from the unprivileged context directly. DEMO.

The implementation contains obtaining of the core configuration by calling the core_getCoreCfg function. Then the scheduler variable in is obtained by the core_getCoreScheduler and the hyper tick, current tick maximum timer tick, timer tick count, schedule table iterator and schedule table elements number are obtained by calling functions scheduler_getSchedulerHyperTick, scheduler_getSchedulerCurrentTick, scheduler_getSchedulerMaxTimerTick, scheduler_getSchedulerTimerTickCount, scheduler_getSchedulerScheduleTableIterator and scheduler_getSchedulerScheduleTableElementsNum. If the schedule table elements number is non-zero value the startick is obtained by calling function scheduler_getSchedulerScheduleTableStartTick. Subsequent if condition checks if the schedule table elements number is non-zero value and if the starttick is equal to the current tick, in this case zero. If condition is true the scheduler_classicSchedulingCore function is called and scheduler state is set to the SCHEDULER_STATE_ENUM__TASK_EXECUTED_IN_WCET_CHECK. If no the functions as macros switchScheduler_performanceScheduling and switchScheduler_classicScheduling are called depends on the SCHEDULER_PERFORMANCE_SCHEDULING macro state (configured via switches). and scheduler state is set to SCHEDULER_STATE_ENUM__WAITING_FOR_START_TIME. The schedulable stack pointer is then set by calling function schedulable_setStackPointer and also schedulable variable is set to the current context by calling function core_setSchedulableIntoCurrentContext and also scheduler state is set by calling scheduler_setSchedulerState function. If condition is implemented to check if the timer ticks that need to be set are more than maximum timer ticks, and if yes than the timer ticks are reduced to the maximum timer ticks. Current tick is then incremented by the timer ticks value modulo hyper tick to not exceed the hyper tick. THe prior tick step is then set by calling scheduler_setSchedulerPriorTickStep function and the current tick by calling scheduler_setSchedulerCurrentTick. The function as macro switchMemoryProtection_setMemoryProtection is called based on the MEMORY_PROTECTION macro state. The operating system state for the current core configuration is set to RESCHEDULE_TRIGGER_STATE_ENUM__SYSTEM by calling core_setCoreOsState function. The scheduler reschedule state is set to RESCHEDULE_TRIGGER_STATE_ENUM__SYSTEM by calling function scheduler_setSchedulerRescheduleTriggerState - this is done only in this place to force system timer overwrite this state when occurs. Then the synchronization barrier function coreSync_getBarrier is called to get in sync with all cores. In the end the system timer is started CILsysTimer_startTimer and the CILstack_setStackPointer called to switch to the schedulable stack.

Parameters

none

Returns

none

StackPointerType scheduler_scheduleNextInstance(StackPointerType stackPointer)

Algorithm for scheduling next schedulable.This function cannot be called from the unprivileged context directly. DEMO.

The implementation contains obtaining of the core configuration by calling the core_getCoreCfg function. Then the scheduler variable in is obtained by the core_getCoreScheduler and the prior schedulable and reschedule trigger state are obtained by calling functions core_getCoreSchedulableInExecution and scheduler_getSchedulerRescheduleTriggerState. Then the switch statement is implemented and contains two states RESCHEDULE_TRIGGER_STATE_ENUM__TIMER and RESCHEDULE_TRIGGER_STATE_ENUM__SYSTEM. The timer reschedule state means that the trigger for the scheduler algorithm execution was timer interrupt. In this case the hyper tick, scheduler state, current tick maximum timer tick, prior tick step, timer tick count, prior schedulable instance type, schedule table iterator, schedule table elements number and start tick are obtained by calling functions scheduler_getSchedulerHyperTick, scheduler_getSchedulerCurrentTick, scheduler_getSchedulerMaxTimerTick, scheduler_getSchedulerTimerTickCount, scheduler_getSchedulerScheduleTableIterator, scheduler_getSchedulerScheduleTableElementsNum and scheduler_getSchedulerScheduleTableStartTick. Then the if condition is implemented to check if the prior schedulable instance type is SCHEDULABLE_INSTANCE_ENUM__THREAD and if yes the stack pointer is stored by calling switchScheduler_schedulable_setStackPointer function based on the SCHEDULER_PERFORMANCE_SCHEDULING macro state. This is needed just for the threads, because the tasks stack is always reused. Next the function as macro switchScheduler_updateAlarms is called based also on the SCHEDULER_PERFORMANCE_SCHEDULING macro state to update all alarms - only if there is performance scheduling active otherwise there are no alarms. Subsequent if condition checks if the schedule table elements number is non-zero value and if the starttick is equal to the current tick, in this case zero. If condition is true the scheduler_classicSchedulingCore function is called and scheduler state is set to the SCHEDULER_STATE_ENUM__TASK_EXECUTED_IN_WCET_CHECK. If no the functions as macros switchScheduler_performanceScheduling and switchScheduler_classicScheduling are called depends on the SCHEDULER_PERFORMANCE_SCHEDULING macro state (configured via switches). and scheduler state is set to SCHEDULER_STATE_ENUM__WAITING_FOR_START_TIME. The schedulable stack pointer is then set by calling function schedulable_setStackPointer and also schedulable variable is set to the current context by calling function core_setSchedulableIntoCurrentContext and also scheduler state is set by calling scheduler_setSchedulerState function. If condition is implemented to check if the timer ticks that need to be set are more than maximum timer ticks, and if yes than the timer ticks are reduced to the maximum timer ticks. Current tick is then incremented by the timer ticks value modulo hyper tick to not exceed the hyper tick. THe prior tick step is then set by calling scheduler_setSchedulerPriorTickStep function and the current tick by calling scheduler_setSchedulerCurrentTick. The function as macro switchMemoryProtection_setMemoryProtection is called based on the MEMORY_PROTECTION macro state. The operating system state for the current core configuration is set to RESCHEDULE_TRIGGER_STATE_ENUM__SYSTEM by calling core_setCoreOsState function. The scheduler reschedule state is set to RESCHEDULE_TRIGGER_STATE_ENUM__SYSTEM by calling function scheduler_setSchedulerRescheduleTriggerState. Then the system timer is set by calling CILsysTimer_setTicks. The system reschedule state means that the trigger for the scheduler algorithm execution was system even such as mutex or putting thread to the sleep state. In this case there is no need to check the start time for another critical task as the system timer has not yet occurred and therefore the prior schedulable instance type has to be in this case SCHEDULABLE_INSTANCE_ENUM__THREAD. Then the stack pointer must be stored by calling schedulable_setStackPointer function. After this point the function scheduler_performanceScheduling is called to schedule next thread for the execution that is then set as schedulable in current context by calling core_setSchedulableIntoCurrentContext function. The function as macro switchMemoryProtection_setMemoryProtection is called based on the MEMORY_PROTECTION macro state. Finally the stackPointerRetVal is returned from the function, that contains the next schedulable stack pointer.

Parameters

stackPointer[in] stack pointer of the current schedulable

Returns

BitWidthType