A thread system is integrated into the NitroSDK. Each thread has an independent context and, by all appearances, is a mechanism that can make multiple modules operate in parallel.

A maximum of 16 threads can be created. (This is the default configuration.) This value is defined with OS_THREAD_MAX_NUM$NitroSDK/include/nitro/os/common/thread.h
Call OS_InitThread() to initialize the thread system. Since calling OS_Init() will initialize the thread system by default, there is no need to call it in the application.
Use OS_IsThreadAvailable() to check whether or not the thread system has been initialized.
Since the program's own thread creation with OS_InitThread()
The threads created with OS_CreateThread()OS_WakeupThreadDirect()
The thread settings include an argument for priority. The thread with the highest priority among the threads in an executable state will run first. The priority is set when the thread is created, but it can be changed by using OS_SetThreadPriority()0 - 31. 0 is the highest-priority thread. If two or more threads have the same priority, it is uncertain which thread takes precedence. Also, there is a special idle thread with priority 32. This thread does nothing. Thread priorities can be obtained with OS_GetThreadPriority()
If a thread is ended with OS_ExitThread()
Below is a list of events that could possibly cause thread switching.
OS_WakeupThread()OS_WakeupThreadDirect()OS_SleepThread()OS_JoinThread()OS_ExitThread()OS_RescheduleThread() was called.
OS_SetThreadPriority()Thread switching also occurs if the message functions OS_SendMessage()OS_ReceiveMessage()
There are also times when thread switching occurs due to thread exclusion control via mutex. This switching occurs when a thread is locked with OS_LockMutex()OS_UnlockMutex()

Even if the function that causes thread switching is called inside the interrupt handler, the thread does not switch immediately. The fact that that event occurred is recorded and, when exiting from the handler, the control moves to the highest-priority executable thread.
In the example below, a function has been called that can switch the three threads (wakeup thread1, wakeup thread2, and wakeup thread3), but at that point it does nothing. When exiting from the interrupt handler, examine all threads and select a thread to be executed from among the executable threads.

In this diagram, it is assumed that the thread switched when there was an interrupt from thread0. If there is no need for thread switching to occur when executing thread0, the interrupts will need to be disabled. There is also the condition that thread0 not call a function that causes an interrupt.
Until control moves to a location where there is a separate thread, there may be cases where that thread wants to stop its execution. There may also be cases where multiple threads are to be awakened at the same time. In such cases, it is convenient to use the thread queue for wakeup.
By initializing the thread queue with OS_InitThreadQueue()OS_SleepThread()OS_WakeupThread()OS_WakeupThread()

It is possible to pause the currently running thread until a certain thread has ended. This operation appears as if the currently running thread and the ending thread have joined, therefore this will be called thread joining throughout this reference.
When in the paused state, the thread that is ending registers the thread for the internal thread queue with OS_JoinThread()OS_WakeupThread()

It is possible to designate a time and use OS_Sleep()OS_InitTick()OS_InitAlarm()
An Overview of OS Functions (Thread)
11/09/2004 Initial version