Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Higher priority task not switched in

Posted by Magnus Kriel on July 15, 2013
I am creating a watchdog (WD) task which monitors all other tasks. If a task does not execute within a set amount of time, the watchdog task will stop kicking the hardware watchdog, forcing a watchdog reset.
To test my WD task I have forced one of the tasks to hang by using a while(1). This task' priority is set to 8 and the watchdog task is set to 6. (Cortex M3 device, lower numeric priority number = higher priority).
After entering the while(1), no other tasks run, not even the higher priority watchdog task. The systick handler is being executed during this time, but the WD task is not being switched in. I did make sure the WD task is actually created successfully and runs.
OS version 7.4.0, Preemption enabled

RE: Higher priority task not switched in

Posted by Richard on July 15, 2013
“Cortex M3 device, lower numeric priority number = higher priority”


That only refers to interrupt priorities, which are controlled by the hardware, not task priorities, which are controlled by the hardware.

A task at priority 8 that is sitting in a null loop without ever entering the Blocked state will prevent a task at priority 6 from ever running, as you have seen. Switch the priorities around and it will be ok.

Regards.

RE: Higher priority task not switched in

Posted by Magnus Kriel on July 16, 2013
Thank you, I tried swapping the priorities and it worked. This, however generates more questions.
I have read through the documentation regarding priorities and and specifically those for the Cortex M3.
If I use the settings that comes with the demo project (#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY15 and #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY5),
1) what range can I use for the task priorities? 1 to 15 or 1 to 255?
2) what range of task priorities will be masked out when entering a critical section?

RE: Higher priority task not switched in

Posted by Richard on July 16, 2013

“1) what range can I use for the task priorities? 1 to 15 or 1 to 255?”


Please do not confuse task priorities and interrupt priorities. Task priorities are under the control of FreeRTOS, are the same for all ports, and are completely unrelated to interrupt priorities (and therefore not restricted in any way to the value of configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY).

On all FreeRTOS ports, 0 is the lowest task priority and (configMAX_PRIORITIES -1) is the highest task priority. configMAX_PRIORITIES is set in FreeRTOSConfig.h.

“2) what range of task priorities will be masked out when entering a critical section?”


No task priorities will be masked out by any critical section....ever.

Only interrupt priorities are masked, and in your case interrupts that have been assigned a priority of 5 or lower will be masked. Note that, due to the irrational way Cortex-M handles interrupt priorities, an interrupt assigned a priority of 4 has a higher logical priority than one assigned a priority of 5 (even though it is a lower number) so will not be masked, whereas an interrupt of priority 6 has a logical priority lower than one assigned a priority of 5 (even though it is a higher number) so will be masked.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner