SuspendAll vs. "SuspendSome"

Hi, not sure if I missed something but I’m lacking a straightforward solution to the following problem:

  • Two tasks, T1 and T2
  • PRIO(T1) > PRIO(T2)
  • T1 does NOT use dynamic allocation at all (e.g. deferred ISR task), DOES have strict latency requirements
  • T2 USES dynamic allocation (e.g. networking task), does NOT have “strict” latency requirements
  • all the dynamic memory management routines (for sake of generality I guess) suspend all the tasks - even those that are guaranteed not to use the dynamic allocation and thus “priority inversion” occurs even without shared resource

regarding the actual ISRs (at least on cortex-M architecture) the clever solution exists to disable IRQs selectively up to some level (which FreeRTOS uses in critical section implementation)

Would it be feasible (and desirable) to have similar solution working with task suspension - e.g. suspending only tasks up to certain priority?

Or would you rather suggest modification of the memory management to avoid using suspension and use a mutex instead?

thanks,

k.

For that problem I would change the memory allocation routine to use a Mutex instead of scheduler suspension, as scheduler suspension isn’t fine enough.

You will have to have something handle making sure the mutex is in place, the simplest is have the memory allocation check if the mutex handle is null, and if so make the mutex with a static creation function so you don’t get stuck in a recursive loop.