Task Pool Terminology
A task pool (or thread pool) is a set of tasks that can asynchronously execute functions (jobs) on behalf of other tasks. This concept is similar to how the FreeRTOS xTimerPendFunctionCall() API function enables a task to defer the execution of a function to the RTOS daemon task. While FreeRTOS contains only one Daemon task, a task pool may contain multiple tasks that execute in parallel.
System Task Pool
A (system task pool) is a task pool that is managed by the IoT Task Pool library. Task pools are divided into two categories (system and application defined). In the demo download provided, the IoT Task Pool library is optimized for MCU development by implementing only the system task pool. Users can switch to the full task pool implementation, which also implements application defined task pools, if that additional capability is needed.
Worker tasks make up the task pool and execute callback functions on behalf of other tasks. These tasks are responsible for executing the jobs that are sent to the task pool.
Jobs are data structures that include a callback function that will be executed by a worker task once they have been scheduled. A job must be created before it can be scheduled by the task pool for execution.
Jobs can be scheduled to be run by a worker task immediately that a worker task is available, or deferred to run at a later time. If a job is scheduled to run immediately when all the worker tasks are already busy then the job is queued until a worker task becomes available.
The job queue contains scheduled jobs. Jobs are removed from the queue through execution by the worker tasks. Jobs can also be removed through cancellation.
Deferred jobs are jobs that are executed at a specified time after they have been sent to the task pool. This is analogous to a FreeRTOS software timer, which is a callback function set to execute after a specified delay.
The job context is data that is specific to the job and it is passed as a parameter to the job’s callback function.