mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-28 02:47:06 +08:00
[kernel/schedule] fix the time slice issue
This commit is contained in:
parent
dd94198bd6
commit
7750358bed
@ -683,8 +683,19 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
|
|||||||
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
||||||
rt_thread_ready_priority_group |= thread->number_mask;
|
rt_thread_ready_priority_group |= thread->number_mask;
|
||||||
|
|
||||||
|
/* there is no time slices left(YIELD), inserting thread before ready list*/
|
||||||
|
if((thread->stat & RT_THREAD_STAT_YIELD_MASK) != 0)
|
||||||
|
{
|
||||||
rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
|
rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
|
||||||
&(thread->tlist));
|
&(thread->tlist));
|
||||||
|
}
|
||||||
|
/* there are some time slices left, inserting thread after ready list to schedule it firstly at next time*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_list_insert_after(&(rt_thread_priority_table[thread->current_priority]),
|
||||||
|
&(thread->tlist));
|
||||||
|
}
|
||||||
|
|
||||||
cpu_mask = RT_CPU_MASK ^ (1 << cpu_id);
|
cpu_mask = RT_CPU_MASK ^ (1 << cpu_id);
|
||||||
rt_hw_ipi_send(RT_SCHEDULE_IPI, cpu_mask);
|
rt_hw_ipi_send(RT_SCHEDULE_IPI, cpu_mask);
|
||||||
}
|
}
|
||||||
@ -697,8 +708,18 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
|
|||||||
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
||||||
pcpu->priority_group |= thread->number_mask;
|
pcpu->priority_group |= thread->number_mask;
|
||||||
|
|
||||||
|
/* there is no time slices left(YIELD), inserting thread before ready list*/
|
||||||
|
if((thread->stat & RT_THREAD_STAT_YIELD_MASK) != 0)
|
||||||
|
{
|
||||||
rt_list_insert_before(&(rt_cpu_index(bind_cpu)->priority_table[thread->current_priority]),
|
rt_list_insert_before(&(rt_cpu_index(bind_cpu)->priority_table[thread->current_priority]),
|
||||||
&(thread->tlist));
|
&(thread->tlist));
|
||||||
|
}
|
||||||
|
/* there are some time slices left, inserting thread after ready list to schedule it firstly at next time*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_list_insert_after(&(rt_cpu_index(bind_cpu)->priority_table[thread->current_priority]),
|
||||||
|
&(thread->tlist));
|
||||||
|
}
|
||||||
|
|
||||||
if (cpu_id != bind_cpu)
|
if (cpu_id != bind_cpu)
|
||||||
{
|
{
|
||||||
@ -733,9 +754,18 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
|
|||||||
|
|
||||||
/* READY thread, insert to ready queue */
|
/* READY thread, insert to ready queue */
|
||||||
thread->stat = RT_THREAD_READY | (thread->stat & ~RT_THREAD_STAT_MASK);
|
thread->stat = RT_THREAD_READY | (thread->stat & ~RT_THREAD_STAT_MASK);
|
||||||
/* insert thread to ready list */
|
/* there is no time slices left(YIELD), inserting thread before ready list*/
|
||||||
|
if((thread->stat & RT_THREAD_STAT_YIELD_MASK) != 0)
|
||||||
|
{
|
||||||
rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
|
rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
|
||||||
&(thread->tlist));
|
&(thread->tlist));
|
||||||
|
}
|
||||||
|
/* there are some time slices left, inserting thread after ready list to schedule it firstly at next time*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_list_insert_after(&(rt_thread_priority_table[thread->current_priority]),
|
||||||
|
&(thread->tlist));
|
||||||
|
}
|
||||||
|
|
||||||
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n",
|
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n",
|
||||||
RT_NAME_MAX, thread->name, thread->current_priority));
|
RT_NAME_MAX, thread->name, thread->current_priority));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user