This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

User Mode and Supervisor mode

The documentation says that: "By default, threads run in supervisor mode and allow access to privileged CPU instructions, the entire memory address space, and peripherals. User mode threads have a reduced set of privileges."

Also, these two modes are related to macros K_KERNEL_STACK and K_THREAD_STACK. In my CoAP(with Open-Thread) example that is provided from NRf-SDK, K_THREAD_STACK_SIZEOF is used. I think, this example choose user-mode threads. 

What is the reason? Can I choose supervisior mode? Documentation says that it is more efficient with using memory and has privileged access to memory space.    

Parents
  • Hi,

    What sample are you looking at, and what version of NCS are you using?

    User mode is only enabled if CONFIG_USERSPACE is defined.

    In the coap_client sample, CONFIG_USERSPACE is not defined (you can check this for yourself by searching for CONFIG_USERSPACE in <your build folder>/zephyr/.config).

     

    In my CoAP(with Open-Thread) example that is provided from NRf-SDK, K_THREAD_STACK_SIZEOF is used.

     I could not find K_THREAD_STACK_SIZEOF being used in any of the Thread samples in NCS v1.5.0. Where did you find it?

    Anyway, I expect it was used because it works for both kernel and user threads.

    Best regards,

    Didrik

Reply
  • Hi,

    What sample are you looking at, and what version of NCS are you using?

    User mode is only enabled if CONFIG_USERSPACE is defined.

    In the coap_client sample, CONFIG_USERSPACE is not defined (you can check this for yourself by searching for CONFIG_USERSPACE in <your build folder>/zephyr/.config).

     

    In my CoAP(with Open-Thread) example that is provided from NRf-SDK, K_THREAD_STACK_SIZEOF is used.

     I could not find K_THREAD_STACK_SIZEOF being used in any of the Thread samples in NCS v1.5.0. Where did you find it?

    Anyway, I expect it was used because it works for both kernel and user threads.

    Best regards,

    Didrik

Children
Related