Don't change priorities of your tasks directly from your user code. Most RTOSes provide APIs that enable us to do this, but it is bad style since it spawns more problems than it will solve. An exception is when certain RTOS functions to this internally (e.g, mutexes with priority inheritance to avoid certain multi-task issues).
I guess you want to have longer critical section only during the power-up phase of your system, or another very special phase of its runtime. Otherwise, you should really listen to @Clifford's comment and question your priority assignments and task decomposition.
If you need that sequential period only during init/power-up phase, this is a typical situation that is possible with good task design, too. In that case, what you need is a runlevel management.
Runlevel Management
The simplest way to implement this is to write a little library on top of your RTOS, using two counting semaphore resources:
One is for the present runlevel, the other for the next one.
When a runlevel is entered, the semaphore is filled as many tokens as there are tasks that must be under control of the runlevel management.
Every task waiting to process a given runlevel is trying to get its token from the current-runlevel semaphore.
When the task has finished its runlevel part, it accesses the next-level semaphore, which will be unavailable at that time.
Before populating the runlevel management configuration, you can draw yourself a
sequence diagram
to check at which points, tasks must wait for others for whatever reason.
Usually for every task, only few of the runlevels are relevant - and per runlevel, the set of relevant tasks may be small too.
Therefore you may want to add a little helper function like WaitForRunlevelNumber(N)
with a loop that automatically deals with those runlevels that aren't relevant.
Runlevel management must finish if all phases that require explicit synchronisation are finished.
Then, all tasks are released into freedom.
Sometimes, you want to release low-priority tasks earlier if they have finished all critical phases yet.
Then the number of tasks maintained may decrease from one runlevel to the next.