This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why can the mesh-stack disable interrupts globally?

I'm currently looking a bit into the bearer-layer internals of the nRF SDK for Mesh and noticed that there is a heap of instances where data needs to be transferred between RADIO IRQ context and any other priority level. Whenever this is done, interrupts get globally disabled using the mesh-internal _DISABLE_IRQS-macro. Of course this is required to prevent access issues to shared resources, which will be used in RADIO IRQ context.

Whenever someone in the dev zone needed to disable interrupts, it was suggested to use APP_CRITICAL_REGION_ENTER, as for example in this question here. This would of course not be applicable to the Mesh-stack, because it needs to exactly lock these interrupts that a "regular application" should not touch.

Why can the mesh-stack lock interrupts globally, seemingly without issue?

Without having it tested extensively, it does not look as if the softdevice does assert from time to time, and I assume you would not want that anyway, so there must be some design limitations that you adhere to in the Mesh-stack that allow for it to not have any negative impact on the Softdevice. What are these?

Parents
  • Hi,

    Since the mesh stack uses SoftDevice timeslots, it stands freer to disable interrupts (during those timeslots). Further, disabling all interrupts will not necessarily lead to problems, as long as it is limited use and for a limited time (preferably less than 20 μs). It is still advisable not to disable more interrupts than strictly needed, and for as short a period as possible.

    Edit: I got some more feedback from our Mesh team, and the only reason they disable all interrupts is that it is strictly necessary in those cases. Extensive testing, isolating pieces of code disabling interrupts as much as possible, collaboration internally with our SoftDevice team, etc. There be dragons.

    Regards,
    Terje

  • Hi Terje,

    Thanks for your response.

    It'd be great if you could elaborate on the following point a bit.

    as it is limited use and for a limited time (preferably less than 20 μs)

    Is this value of 20us based on experience, a piece of documentation or anything you could point me to?

    Does the mesh stack adhere to these timings (I assume so...)?

    the only reason they disable all interrupts is that it is strictly necessary in those cases

    I can imagine... as mentioned above, I see that this is absolutely required to not get data inconsistencies. I just wondered whre the limits were.

    Thanks.

    Best regards,

    -mike

Reply
  • Hi Terje,

    Thanks for your response.

    It'd be great if you could elaborate on the following point a bit.

    as it is limited use and for a limited time (preferably less than 20 μs)

    Is this value of 20us based on experience, a piece of documentation or anything you could point me to?

    Does the mesh stack adhere to these timings (I assume so...)?

    the only reason they disable all interrupts is that it is strictly necessary in those cases

    I can imagine... as mentioned above, I see that this is absolutely required to not get data inconsistencies. I just wondered whre the limits were.

    Thanks.

    Best regards,

    -mike

Children
No Data
Related