Skip to content
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Home
  • GeMRTOS
    • GeMRTOS repository
    • GeMRTOS Knowledge base
  • Log in
  • Contact us
Search
  • FPGA Laboratory ACCESS
  • Cursos de FPGA (en español)
    • VHDL para diseño en dispositivos FPGA
    • Configuración de Quartus Prime y Laboratorio remoto de FPGA
  • Desafíos FPGA (en español)
    • Desafío sobre Laboratorio remoto de FPGA
    • Desafío sobre Quartus Prime.
    • Desafió sobre funciones y compuertas lógicas
    • Desafío sobre estructura de VHDL y flujo de diseño
    • Desafío sobre procesos en VHDL
    • Desafío sobre Máquinas de estados y descripción jerárquica
    • Desafío sobre señales, vectores y representaciones numéricas
    • Desafío sobre simulación con testbench
    • Desafío sobre estructuras en VHDL y parametrización
    • Desafío sobre funciones, procedimientos, paquetes y librerías
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • GeMRTOS
    • GeMRTOS repository
    • GeMRTOS Knowledge base
  • Login
  • Contact us
  • FPGA Laboratory ACCESS
  • Cursos de FPGA (en español)
  • Challenges

GeMRTOS - Getting started

  • Creating your first GeMRTOS application
  • Introduction to GeMRTOS
  • Platforn Designer flow
  • Installation of Quartus Prime with WSL ([1]) for GeMRTOS design flow.

GeMRTOS - Features

  • Signals in GeMRTOS
  • GeMRTOS system architecture
  • Introduction to GeMRTOS: Hybrid partition scheduling.
  • Scheduling lists in GeMRTOS
  • Tasks in GeMRTOS
  • GeMRTOS Controller
  • Data structures and linked lists in GeMRTOS
  • Semaphores in GeMRTOS
  • Triggers in GeMRTOS
  • Message queue in GeMRTOS

General

  • Compiling beyond 256MB
  • Questa issues
  • Warning (113015): Width of data items in <mem_init>.hex is greater than the memory width
  • Processors with an ID other than 1 do not launch once the software has been downloaded.
  • System console does not start after Quartus Prime instalation
  • Eclipse does not start after full Quartus Prime instalation
  • Home
  • GeMRTOS KnowledgeBase
  • Tasks in GeMRTOS

Tasks in GeMRTOS

Table of Contents
  • Tasks in GeMRTOS
  • Types of GeMRTOS tasks
  • Main task related functions
    • Creating and initializing a task
    • Starting task execution
    • Suspending the execution of a task for a certain interval

Tasks in GeMRTOS #

A task in GeMRTOS is defined as a unit of execution. The main components of a task implementation are:

  • GS_TCB: this is a control block that stores the information required for task management.
  • task code: this is the executable code, loaded into the system memory, that implements a task function when it is executed by a processor. Task code is implemented a subroutine function.
  • task stack: this is data storage to preserve the status of a suspended task in order to resume it properly and store subroutine data. The task stack memory is reserved when the task is created. The amount of memory assigned to the task stack is defined by default.

Types of GeMRTOS tasks #

The following are the type of tasks in GeMRTOS, but more can be defined:

tcbtype
Enumerator
G_TCBType_UCOS

The G_TCBType_UCOS task type makes the task code to be executed just once. The task must be released once again for another execution if the task code does not contain an infinite loop. Initialization tasks may be implemented as a G_TCBType_UCOS task type without infinite loop in the task code. G_TCBType_UCOS tasks are often implemented as an infinite loop to keep them running. When a task with an infinite loop is executed, it will take as much processor time as possible. It is possible to use different strategies to prevent one or many system tasks from being overly greedy about processor time and starving the others:

  • Assigning lowest priorities to tasks: in this way, infinite-loop tasks will be executed only when the highest priority tasks are not requiring for execution.
  • Suspending the task until an event: the task is suspended inside the infinite loop, waiting for an event. The events may be timed events (to execute the task regularly) or trigger events (such as waiting for an interrupt).
  • Reducing the task priority: the task priority may be reduced inside the infinite loop to let the new higher-priority task be executed. This tactic should be implemented in all the infinite-loop tasks of the scheduling list to dynamically preserve a valid relationship among the system task priorities.
  • Defining a round-robin scheduling mechanism in the scheduling list: a round-robin mechanism will execute each task during a certain interval, granting the processor access to each task in the scheduling list.
G_TCBType_PERIODIC

The G_TCBType_PERIODIC task type makes the task code to be executed periodically. The period of the task is configured when the type is specified. The period of the task and the initial offset determines the future releases times of the task. If previous invocation of the task does not completes, then the previous invocation may be defined to be aborted or the next release skipped. Periodic tasks are useful to meet Nyquist and Shannon theorems in cyber-physical applications. However, if no scheduling analysis is performed, the system may became oversaturated and the deadlines missed.

Remarks
G_TCBType_PERIODIC
G_TCBType_ISR

The G_TCBType_ISR task type determines that the task is associated with a trigger resource. The G_TCBType_ISR type of the task should be set after the task is created using the gu_trigger_register_task function.

Remarks
G_TCBType_ISR
G_TCBType_IDLE

The G_TCBType_IDLE task type determines the task that a processor executes when no task requires for execution. The IDLE task is a GeMRTOS system task and there is one for each system processor. By default, the G_TCBType_IDLE task turns the processor into sleep mode in order to save energy and reduce the system bus utilization.

Remarks
G_TCBType_IDLE
G_TCBType_UNDEFINED

Task type UNDEFIEND. When not a specific type is given to the task

Remarks
G_TCBType_UNDEFINED

Main task related functions #

Creating and initializing a task #

A task can easily be created using:

void * gu_GetTask (void * TaskCode, void * p_arg, char * format,  ... )

The gu_GetTask function creates a task with all the default assignments and returns a pointer to a GS_TCB structure of the new task. All the parameters of the task may be determining by changing the default assignments prior to task creation and most of them may be change after task creation through task related functions. The gu_GetTask function requieres only two parameters: (1) a pointer to the function subroutine that implements the task code (i.e. it is the name of the function), and (2) an argument to be passed each time that the task is invoked. The task is created with the following default values:

  • Type: defined in the G_TASK_TYPE_DEFAULT parameter, set with the gu_Set_Default_Task_Type() function. After creation, type parameter of the task may be modified with: (1) the gu_trigger_register_task() function for triggerable task, or (2) gu_SetTaskType() function.
  • Ready Priority: defined in the G_TASK_PRIORITY_DEFAULT parameter, set with the gu_Set_Default_Task_Priority() function. After creation, ready priority parameter may be set with the gu_SetTaskReadyPriority() function.
  • Run Priority: defined in the G_TASK_PRIORITY_DEFAULT parameter, set with the gu_Set_Default_Task_Priority() function. After creation, run priority parameter may be set with the gu_SetTaskRunPriority() function.
  • Deadline: defined in the G_TASK_PERIOD_DEFAULT parameter, set with the gu_Set_Default_Task_Period() function. After creation, deadline parameter may be set with the gu_SetTaskDeadline() function.
  • Period: defined in the G_TASK_PERIOD_DEFAULT parameter, set with the gu_Set_Default_Task_Period() function. After creation, period parameter may be set with the gu_SetTaskPeriod() function.
  • Scheduling list: defined in the G_TASK_LCB_DEFAULT parameter, set with the gu_Set_Default_Task_List() function. After creation, scheduling list parameter may be set with the gu_SetTaskList() function.
  • Abort when invoked: set to G_TRUE by default. By default, task is aborted when it is released before completion. After creation, abort when invoked parameter may be set with the gu_SetTaskAbortwhenDeadline() function.

The task is created with the following paramenters:

TaskCodeit is a pointer to the beginning of the task code. It is the name of the function that implements the task code.
p_argit is a pointer that it is passed to the task function each time it is invoked. It is defined as a "void *" type, but it may be casted for different types inside the task code.
formatFormatted task_description string for description of the task up to G_TCB_DESCRIPTION_LENGTH character length. The valid format of this task_description is similar to the original printf function, allowing it to contain embedded format tags. These format tags can be replaced by the values specified in subsequent additional arguments and formatted as specified. This allows for flexible and customized task_description formatting within the gu_GetTask function, akin to how the printf function operates.
Returns
The gu_GetTask function returns a pointer to the GS_TCB structure of the task created. This value should be used to reference all the function called related to the task created.

Starting task execution #

A task is schedule to start execution using:

G_INT32 gu_StartTaskwithOffset (struct gs_tcb * ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms )

The gu_StartTaskwithOffset function sets a previously created task for execution. The gu_StartTaskwithOffset function allows defingning an offset for the first time execution of the task. This offset helps to schedule the starting time of the tasks.

The task is started with the following paramenters:

ptcbIt is a pointer to the GS_TCB structure of the task (returned by the gu_GetTask() function when task was created).
hoursNumber of hours of the starting offset.
minutesNumber of minutes of the starting offset.
secondsNumber of seconds of the starting offset.
msNumber of miliseconds of the starting offset.
Returns
The gu_StartTaskwithOffset function returns G_TRUE when successful.

Suspending the execution of a task for a certain interval #

A task can be suspended for a certain interval using:

G_INT32 gu_TASK_Sleep (G_INT32 hours, G_INT32 minutes, G_INT32 seconds, G_INT32 ms )

The gu_TASK_Sleep function suspends the execution of the current task for a defined interval. This function may be used inside of the infinite loop of a run-once task, in order to produce a repetitive execution of the code in the loop.

The task is suspended with the following paramenters:

hoursNumber of hours of the suspension interval.
minutesNumber of minutes of the suspension interval.
secondsNumber of seconds of the suspension interval.
msNumber of miliseconds of the suspension interval.
Returns
The gu_TASK_Sleep function returns G_TRUE.
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Leave a Reply Cancel reply

You must be logged in to post a comment.

Table of Contents
  • Tasks in GeMRTOS
  • Types of GeMRTOS tasks
  • Main task related functions
    • Creating and initializing a task
    • Starting task execution
    • Suspending the execution of a task for a certain interval

Copyright © 2023 - contact@gemrtos.com - dorrego 289 - B8000FLE - bahía blanca - argentina  GeMRTOS

Nios II, Quartus Prime, ModelsSim are property of their respective companies.
GeMRTOS is property of R. Cayssials.
**All contact forms on this site are protected by reCAPTCHA. Google Privacy