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


How does ulCriticalNesting work?

Posted by Nobody/Anonymous on September 20, 2006
Forgive me for what may be a very poor question. Maybe I just need to write this out... This is related to my work on the AT91SAM7S256 port of FreeRTOS (using WinARM to compile).

How is ulCriticalNesting supposed to work? I think that what I am seeing is that whenever a task is created, vPortEnterCritical() is called which increments ulCriticalNesting (initially it is 9999UL so now it would be 10000UL). When the creation of the task is complete then it calls vPortExitCritical() and first checks to see if ulCriticalNesting is greater than 0. It is. Then it decrements ulCriticalNesting (back to 9999UL in this case) and checks if ulCriticalNesting is equal to 0. It is NOT. Since it is NOT, then it does NOT enable the interrupts.

Am I not understanding this code correctly? How will ulCriticalNesting ever allow for the interrupts to be enabled again?


RE: How does ulCriticalNesting work?

Posted by Richard on September 20, 2006
ulCriticalNesting - I think I said uxCriticalNesting in my reply to another post a few moments ago which may be related to this question.

ulCriticalNesting is stored as part of the task context. It is initialised to zero *within the task* - so when a task starts executing it will get set to zero. As per my previous post if you set a break point at the start of the task, then inspect ulCriticalNesting, you should find that it is zero.

Before the scheduler is started ulCriticalNesting is set to a non-zero value to prevent it ever reaching zero before the scheduler is properly initialised. It will be overwritten with zero when the first task starts.


[ 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