The problem is to define the priority on a task-level. Every task can call a critical function, so the priority has to be raised there.
My solution is a task-lock that works with a mutex. The task is marked exclusive, so interrupts are kept disabled after the task-switch until the task-lock is released.
You can take a look at the heap for example. It is used by every task and is a critical function. I'm using a task-lock there.
Best regards,
Sven Bieg