Git Product home page Git Product logo

Comments (13)

RichardBarry avatar RichardBarry commented on August 28, 2024 1

I will add this in to the SVN repo, under the existing xPortIsInsideInterrupt() utility function.

from freertos-kernel.

RichardBarry avatar RichardBarry commented on August 28, 2024 1

...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.

RichardBarry avatar RichardBarry commented on August 28, 2024

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.

0x3333 avatar 0x3333 commented on August 28, 2024

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.

RichardBarry avatar RichardBarry commented on August 28, 2024

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.

0x3333 avatar 0x3333 commented on August 28, 2024

Exactly. But the problem is that it is port dependent.

from freertos-kernel.

0x3333 avatar 0x3333 commented on August 28, 2024

A function like UBaseType_t xIsInsideCriticalSection( void ); would be more generic, usable in some ports that don't you nesting.

from freertos-kernel.

0x3333 avatar 0x3333 commented on August 28, 2024

Like:

portFORCE_INLINE UBaseType_t xIsInsideCriticalSection( void )
{
     return ( uxCriticalNesting > 0 ) ? pdTRUE : pdFALSE;
}

from freertos-kernel.

0x3333 avatar 0x3333 commented on August 28, 2024

You are right. I'm using GCC ARM Cortex M0, M3 and M4. IIRC they use uxCriticalNesting.

from freertos-kernel.

0x3333 avatar 0x3333 commented on August 28, 2024

Hi! Do you believe is possible to provide the uxGetCriticalNestingDepth function?

from freertos-kernel.

RichardBarry avatar RichardBarry commented on August 28, 2024

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.

0x3333 avatar 0x3333 commented on August 28, 2024

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.

josesimoes avatar josesimoes commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.