Electronic – differences between privileged mode and unprivileged mode in the RTX RTOS

cortex-m3rtos

As i said in the title what's differences between privileged mode and unprivileged mode in the RTX RTOS?
And why in privileged mode threads has allowed full access to the cortex M processor?

Best Answer

From the RTX Documentation

Processor Mode for Thread Execution

CMSIS-RTOS RTX allows to execute threads in unprivileged or privileged processor mode. The processor mode is controlled with the #define OS_RUNPRIV.

In unprivileged processor mode, the software:

  • has limited access to the MSR and MRS instructions, and cannot use the CPS instruction.
  • cannot access the system timer, NVIC, or system control block.
  • might have restricted access to memory or peripherals.

In privileged processor mode the software can use all the instructions and has access to all resources.

Note It is recommended to use the privileged processor mode.

Privileged and Unprivileged mode is really a feature of the ARM core and RTX is simply making that feature available. If your application has a reason to restrict privileges for threads than you might choose unprivileged mode. But I suspect most applications use privileged mode and allow all threads full privilege.