RTT supports the same priority, but ucoⅱ does not.
If a thread does not call the rt-thread_delay () to let out the scheduler, it will always run, and other threads will always be in the ready state.
A thread with the same priority defines the longest time slice for a single run during initialization or creation, and forces the thread to exit the scheduler.
Here, usert_thread_yield();
You can also give way to the dispatcher.
# Include <rtthread. h> rt_thread_t tid1 = rt_null; rt_thread_t tid2 = rt_null; static void thread1_entry (void * parameter) {rt_uint32_t COUNT = 0; while (1) {rt_kprintf ("thread1: count = % d \ n ", Count ++); rt_thread_yield () ;}} static void thread2_entry (void * parameter) {rt_uint32_t COUNT = 0; while (1) {rt_thread_yield (); rt_kprintf ("thread2: Count = % d \ n", Count ++) ;}}/* must have the same priority, otherwise, a thread is ready after the scheduler is released. The queue, which has a higher priority than the other thread, will continue to run, making the other thread unable to run. */INT rt_application_init () {tid1 = rt_thread_create ("T1", thread1_entry, rt_null, 512, 6, 10); If (tid1! = Rt_null) rt_thread_startup (tid1); tid2 = rt_thread_create ("T2", thread2_entry, rt_null, 512, 6, 10); If (tid2! = Rt_null) rt_thread_startup (tid2); Return 0 ;}/*@}*/
Output result:
\ | /- RT - Thread Operating System/ | \ 1.1.0 build Aug 10 20122006 - 2012 Copyright by rt-thread teamthread1: count = 0thread1: count = 1thread2: count = 0thread1: count = 2thread2: count = 1thread1: count = 3thread2: count = 2thread1: count = 4thread2: count = 3thread2: count = 4