Quality RTOS & Embedded Software

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


AT9140008 - ulcriticalNesting

Posted by Nobody/Anonymous on July 4, 2006
In the portSAVE_CONTEXT macro, What does the statement do?
( void ) ulCriticalNesting;

ulCriticalNesting - this variable is used to keep track of how many times we have entered in a crtical area and not exited yet. One of the actions that is done in the enter Critical is to disable interrupts by manipulating I and F bits.
All thru the code, this variable is manipulated by using portENTER_CRITICAL and portEXIT_CRITICAl - which are called as a pair. When does this variable get incremented without being decremented in the code?

An example would help?


RE: AT9140008 - ulcriticalNesting

Posted by Richard on July 4, 2006
>In the portSAVE_CONTEXT macro, What does the
>statement do?
>( void ) ulCriticalNesting;

Stops compiler warnings. Nothing else.

>When does this variable get incremented without
>being decremented in the code

They must always get called in pairs, but it is possible for the calls to be nested. Therefore calling EXIT_CRITICAL() will not necessarily result in the variable being set back to zero.

The reason the critical nesting is stored as part of the task context is because each task maintains its own interrupt status. It is possible to yield from a critical section to a task that has interrupts enabled. The reason you might want to do this is if you want to guarantee that interrupts are disabled when the task that yielded next executes.


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

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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

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

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


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





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