Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists