Comments (13)
I will add this in to the SVN repo, under the existing xPortIsInsideInterrupt() utility function.
from freertos-kernel.
...except it can't be an inline function in a header as uxCriticalNesting is not accessible from there. I was thinking more as per the following as all ports support critical section nesting:
UBaseType_t uxGetCriticalNestingDepth( void )
{
return uxCriticalNesting;
}
This would have to be added into each port layer. The variable that counts the nesting depth is not always called the same thing. Which specific port are you using (including the compiler) as I can start with that one.
from freertos-kernel.
The code you post returns whether or not interrupts are masked or not, rather than whether you are inside a critical section or not - is that what you want/need? There are other ways interrupts could get masked other then entering a critical section.
from freertos-kernel.
Technically speaking you are right. I need to know if I'm inside a critical section or not, more specifically if vPortEnterCritical
was called or not. I believe the best way is to use the uxCriticalNesting
, checking if it is 0
or not.
In my case, I'm checking if a function has been called inside a critical section, not if interrupts are masked or not.
In ChibiOS there are some functions(ending in I
) that must be called from a critical section, and when assertions are enabled I need to check. That is why I need to know.
from freertos-kernel.
So would it be better to add something into the port layer along the lines of:
UBaseType_t uxGetCriticalNestingDepth( void );
that returns the critical nesting count depth - zero meaning you are not in a critical section?
from freertos-kernel.
Exactly. But the problem is that it is port dependent.
from freertos-kernel.
A function like UBaseType_t xIsInsideCriticalSection( void );
would be more generic, usable in some ports that don't you nesting.
from freertos-kernel.
Like:
portFORCE_INLINE UBaseType_t xIsInsideCriticalSection( void )
{
return ( uxCriticalNesting > 0 ) ? pdTRUE : pdFALSE;
}
from freertos-kernel.
You are right. I'm using GCC ARM Cortex M0, M3 and M4. IIRC they use uxCriticalNesting
.
from freertos-kernel.
Hi! Do you believe is possible to provide the uxGetCriticalNestingDepth
function?
from freertos-kernel.
It is not that straight forward because this needs to be in the port layer, and there are a LOT of different port layers that would then need slightly different implementations and testing. I would like to propose a slightly different idea. tasks.c provides a mechanism that enables enables users to add their own functions in to the file without needing to change the source file - you do that by setting a #define in the FreeRTOSConfig.h file then providing a header file called freertos_task_c_additions.h - we could do something similar in the port.c files - that way the same code would be added to the bottom of each port.c file and it would allow you to add your own access function (or any other port specific function) into a header file and have it included in the file.
Thoughts?
from freertos-kernel.
I understand, sure it is a massive work. Your suggestion would be killer, much more flexible. I can implement only the ports I need.
from freertos-kernel.
Hello!
I'm after this xPortIsCriticalSection in GCC ARM Cortex M0.
Any update on when this (or the workaround above) is available?
Thanks!
from freertos-kernel.
Related Issues (20)
- pvPortRealloc Implementation in AVR32_UC3 Port HOT 1
- [BUG]
- Five heaps to choose? HOT 4
- [Feature Request] The number of system calls needs to support the sizeof(uintptr_t) HOT 4
- [DOC] HOT 1
- Will timer task be created twice for smp x2 freertos HOT 1
- [Feature Request] Queue Sets with ability to add the same object to several Sets
- [BUG] Premature changing of pxCurrentTCB BEFORE actual context switch in Win32/64 Port HOT 1
- [BUG] Violation of MISRA2012 rule 17.11 - A function that never returns should be declared with a _Noreturn function specifier HOT 6
- [BUG] Violation of MISRA 2012 Rule 5.5: Identifiers shall be distinct from macro names HOT 3
- Minimize the use of the taskENTER_CRITICAL and taskEXIT_CRITICAL HOT 3
- [DOC] xQueueOverwrite Queue Length HOT 2
- [BUG] Missing `extern "C"` guard in MSVC portmacro.h HOT 1
- [BUG] Violation of MISRA 10.4: Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category HOT 2
- [BUG] vTaskDelay raises configASSERT when SMP is on HOT 2
- [Feature Request] Add CodeSonar example to the repository HOT 1
- FreeRTOS posix port hangs when issuing interrupt-safe calls from an external thread HOT 3
- [BUG] FreeRTOS install with Pico-SDK fails (CMAKE_C_COMPILER_OBJECT) HOT 1
- [BUG] I used Posix gcc to compile on glibc 2.24 and gcc 6.3.0, but failed to compile the demo HOT 5
- [BUG]traceMALLOC() memory count is inaccurate HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freertos-kernel.