Page 3 of 3
The Standard Tasks
Working with the scheduling algorithm would be easy if there were only the tasks you created in the system. There are, however, standard tasks that the system starts before your program is loaded:
Task Name
|
Description
|
Affinity
|
Priority
|
Idle Task (IDLEx)
|
Created for each core x.
|
Core x
|
0
|
Timer Task (Tmr Svc)
|
Created by FreeRTOS when any FreeTOS Timer APIs is called
|
Core 0
|
CONFIG_FREERTOS_TIMER_TASK_PRIORITY
|
These tasks aren’t running all of the time, but the priorities that you assign to tasks that you create can stop them running at all and this is not a good idea. The Idle Task is responsible for freeing the kernel-allocated memory from tasks that have been deleted. It is therefore important that the Idle Task is not starved of microcontroller processing time if your application makes any calls to vTaskDelete. Memory allocated by a task is not automatically freed and should be freed before the task is deleted.
In chapter but not in this extract
- A First Example
- The Timing Problem
- Managing Tasks
- A Better Main
- Race Conditions
- Update Loss
- Locks
- Queues
- WiFi
- FreeRTOS Web Client
- FreeRTOS Considered
Summary
-
FreeRTOS is an open source project to make a realtime operating system available on a wide range of processors.
-
The version of FreeRTOS used by the Pico is available on the Raspberry Pi website and this has been extended to work with two cores to utilize Symmetric Multi-Processing (SMP).
-
FreeRTOS works in terms of tasks. A task is a function that can be run as if it was a “main” program in its own right. Tasks never return and are generally written as infinite loops.
-
Each task has a priority and tasks get to run on a processor according to their priority.
-
At each tick, the scheduler stops the current task and selects the task with the highest priority to run next.
-
Tasks with equal priority take equal turns to run.
-
As well as the custom tasks a program creates, there are some standard tasks created by the system.
-
A range of functions allows you to control how tasks are run.
-
The problem with multi-tasking is the danger of creating race conditions where the outcome of a computation depends on the order in which tasks are run.
-
To avoid race conditions you have to use locks to restrict access to shared resources.
-
An alternative to using locks is to use safe data structures such as xQueue to allow tasks to interact and pass data to each other.
-
You can run the WiFi libraries on either core as a FreeRTOS task.
-
To avoid race hazards, a single WiFi task running on a single core is a good design choice.
-
Implementing a web client using FreeRTOS is little different from working without FreeRTOS.
Master the Raspberry Pi Pico in C: WiFiwith lwIP, mbedTLS & FreeRTOS Second Edition
By Harry Fairhead & Mike James

Buy from Amazon.
Contents
Preface
- The Pico WiFi Stack
- Introduction To TCP
Extract: Simplest HTTP Client *
- More Advanced TCP
- SSL/TLS and HTTPS
Extract: Simplest HTTPS Client *
- Details of Cryptography
Extract: Random Numbers*
- Servers
Extract: HTTP Server *
- UDP For Speed
Extract: Basic UDP *
- SNTP For Time-Keeping
- SMTP For Email
- MQTT For The IoT
- FreeRTOS
Extract: Installing FreeRTOS NEW!!
- Client Sockets
- Socket Server
- Secure Sockets
Appendix 1 Getting Started In C
* Extracts from the first edition not yet updated.
<ASIN:B0FDYDPQ54>
|