FreeRTOS术语

以下术语解释为本人在学习FreeRTOS途中的整理,大多直接引用了官网的原解释,部分用自己的话进行描述。

1. Task

Task is used to process a serial of things. A task must be declared as void type and have a void-type pointer parameter , like: void BLE_TASK(void * pvParameters);

And when used, it’s used in the function xTaskCreate() with 6 parameters, like: xTaskCreate(BLE_TASK, “BEL_TASK”,4000, NULL, 5, NULL);

  • The 1st parameter should be the task you defined, and it only need the name of your task function.
  • The 2nd parameter is the custom string you made in order to recognize it in the tasks list.
  • The 3rd parameter is task stack memory it need. MEMORY = STACK DEPTH * STACK WIDTH
  • The 4th parameter is passed to the the task when it need, and it used to be NULL.
  • The 5th parameter is the priority of the task, the lowest priority is 0, the highest priority is 32. But it always advisable to keep it at the minimum necessary.
  • The 6th parameter is the return value: pdPASS or pdFAIL.

2. Scheduler

Scheduler is used to manage the tasks. It runs in the tick interrupt and select the highest priority task and bring it into RUNNING-STATE.

3. IDLE Task

IDLE Task is automatically created by the scheduler when vTaskStartScheduler() is called and it is always able to run.

4. Task State

All the task has two big states: RUNNING-STATE or NOT-RUNNING-STATE. BLOCKED-STATE, SUSPENDED-STATE and SUSPENDED-STATE are NON-RUNNING-STATE.

Task State

4.1 RUNNING-STATE

When the task is running, it is in the RUNNING-STATE.

4.2 BLOCKED-STATE

BLOCKED-STATE is a sub-state of NOT-RUNNING STATE. Tasks can enter the BLOCKED-STATE to wait for two different types of event: Temporal Event & Synchronization Events. While in this state, tasks are not able to run, so cannot be selected by the scheduler.

4.3 SUSPENDED-STATE

SUSPENDED-STATE is a sub-state of NOT-RUNNING STATE.

4.4 READY-STATE

READY-STATE is a sub-state of NOT-RUNNING STATE.

5. Event

Event is also called Interrupt. It is originated by the environment and force the embedded system to take action in response to it.

6. Event-drive task

Event-drive task has work after the event that triggers it, and is not able to enter the RUNNING-STATE before that event has occurred.

7. Semaphore(s)

  1. Binary Semaphore
  2. Counting Semaphore

8. Queue(s)

Queue provides a task-to-task, task-to-interrupt, interrupt-to-task communication mechanism.

9. Event Group(s)

Event groups are another feature of FreeRTOS that allow events to be communicated to tasks.

10. ISR

Interrupt Service Routine. It is a software process invoked by an interrupt request from a hardware device. It handles the request and sends it to the CPU, interrupting the active process. When the ISR is complete, the process is resumed.

11. Task & Event(Interrupt)

A task is a software feature that is unrelated to the hardware on which FreeRTOS is running. The priority of a task is assigned in software by the application writer, and a software algorithm (the scheduler) decides which task will be in the Running state.

Although written in software, an interrupt service routine is a hardware feature because the hardware controls which interrupt service routine will run, and when it will run. Tasks will only run when there are no ISRs running, so the lowest priority interrupt will interrupt the highest priority task, and there is no way for a task to pre-empt an ISR.

Reference

  1. <FreeRTOS Documentation>
  2. <API>