File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -91,8 +91,7 @@ void rt_tick_increase(void)
9191
9292 thread -> stat |= RT_THREAD_STAT_YIELD ;
9393
94- /* yield */
95- rt_thread_yield ();
94+ rt_schedule ();
9695 }
9796
9897 /* check timer */
Original file line number Diff line number Diff line change @@ -346,9 +346,9 @@ void rt_schedule(void)
346346 }
347347 else
348348 {
349- current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
350349 rt_schedule_insert_thread (current_thread );
351350 }
351+ current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
352352 }
353353 to_thread -> oncpu = cpu_id ;
354354 if (to_thread != current_thread )
@@ -444,9 +444,9 @@ void rt_schedule(void)
444444 }
445445 else
446446 {
447- rt_current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
448447 need_insert_from_thread = 1 ;
449448 }
449+ rt_current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
450450 }
451451
452452 if (to_thread != rt_current_thread )
@@ -595,9 +595,9 @@ void rt_scheduler_do_irq_switch(void *context)
595595 }
596596 else
597597 {
598- current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
599598 rt_schedule_insert_thread (current_thread );
600599 }
600+ current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
601601 }
602602 to_thread -> oncpu = cpu_id ;
603603 if (to_thread != current_thread )
Original file line number Diff line number Diff line change @@ -478,7 +478,15 @@ RTM_EXPORT(rt_thread_delete);
478478 */
479479rt_err_t rt_thread_yield (void )
480480{
481+ struct rt_thread * thread ;
482+ rt_base_t lock ;
483+
484+ thread = rt_thread_self ();
485+ lock = rt_hw_interrupt_disable ();
486+ thread -> remaining_tick = thread -> init_tick ;
487+ thread -> stat |= RT_THREAD_STAT_YIELD ;
481488 rt_schedule ();
489+ rt_hw_interrupt_enable (lock );
482490
483491 return RT_EOK ;
484492}
You can’t perform that action at this time.
0 commit comments