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
>( 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.