Exploring the threads

Use the kernel thread list shell command to examine the running threads. You should be able to identify the following ones:

  • idle: the idle thread, which takes care of putting the system to sleep. Zephyr will run the threads with lower priority values first. The idle thread has the highest priority value, which means that it will run only when nothing else needs to run.

  • shell_uart: the shell we are executing commands into. The shell runs into its own thread. It uses a very low priority task (with a high numerical value) as to not disturb the system it is interacting with.

  • sysworkq: Zephyr default workqueue. A workqueue is a thread on which jobs are sent to be executed serially, for example from an interrupt service routine (ISR). Note the negative priority: the workqueue is a very important thread.

Finding main

However, we don't see main in the list. Indeed, our main function exits as soon as it has printed.

Add an infinite loop at the end of main(). Why can't you use the shell? Use a proper way of making main() wait forever without consuming any resource. Zephyr documentation will be a very useful resource. Do not forget to include zephyr/kernel.h to use kernel services.

Find the priority of the main thread. Change it in the project configuration file and check that it has been properly set.