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 @@ -350,9 +350,9 @@ void rt_schedule(void)
350350 }
351351 else
352352 {
353- current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
354353 rt_schedule_insert_thread (current_thread );
355354 }
355+ current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
356356 }
357357 to_thread -> oncpu = cpu_id ;
358358 if (to_thread != current_thread )
@@ -448,9 +448,9 @@ void rt_schedule(void)
448448 }
449449 else
450450 {
451- rt_current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
452451 need_insert_from_thread = 1 ;
453452 }
453+ rt_current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
454454 }
455455
456456 if (to_thread != rt_current_thread )
@@ -599,9 +599,9 @@ void rt_scheduler_do_irq_switch(void *context)
599599 }
600600 else
601601 {
602- current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
603602 rt_schedule_insert_thread (current_thread );
604603 }
604+ current_thread -> stat &= ~RT_THREAD_STAT_YIELD_MASK ;
605605 }
606606 to_thread -> oncpu = cpu_id ;
607607 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