Before learning about the thread manipulation functions, you must understand the ThreadQueue class, and the principles of thread scheduling in uCR.
# include <ucr/ThreadQueue.h> struct THREAD; class ThreadQueue;
The ThreadQueue class is a container for thread objects, which are represented by values of type THREAD*. uCR internally has one instance of class ThreadQueue that it uses as a run queue.
The ThreadQueue class is basically a queue that supports append, prepend and pull. Append and pull together implement a queue, and prepend and pull together implement a stack. The uCR scheduler simply runs the thread on the front of the run queue object. It will continue to run that thread until the scheduler is invoked to reschedule the cpu and, if necessary, switch the current thread.
Threads can only be in one ThreadQueue at a time. The application does not have direct access to the run queue object, but a runnable thread can be pulled out of the run queue by putting it into a ThreadQueue object elsewhere. A subsequent reschedule will then cause uCR to notice that the thread is not runnable and if it is running, switch it out.
The thread manipulation tools that uCR provides use ThreadQueue classes to control the scheduling of threads. They generally strive for a non-preemptive FIFO policy, although interrupt handlers may explicitly rearrange the run queue to cause preemption.