Prevent task switching during specific code execution

This is a pretty good thread when to use which tool for mutual exclusion:

In case you simply want to have the code executed as fast as possible and deterministically i.e. without any interruption you have to use a critical section.
If you’re using interrupts outside FreeRTOS covered (priority) range you might want disable interrupts globally e.g. using __disable/enable_irq intrinsics for ARM MCUs.