[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 */
|
||||
rt_thread_ready_priority_group |= thread->number_mask;
|
||||
|
||||
rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
|
||||
&(thread->tlist));
|
||||
/* 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]),
|
||||
&(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);
|
||||
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 */
|
||||
pcpu->priority_group |= thread->number_mask;
|
||||
|
||||
rt_list_insert_before(&(rt_cpu_index(bind_cpu)->priority_table[thread->current_priority]),
|
||||
&(thread->tlist));
|
||||
/* 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]),
|
||||
&(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)
|
||||
{
|
||||
|
@ -733,9 +754,18 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
|
|||
|
||||
/* READY thread, insert to ready queue */
|
||||
thread->stat = RT_THREAD_READY | (thread->stat & ~RT_THREAD_STAT_MASK);
|
||||
/* insert thread to ready list */
|
||||
rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
|
||||
&(thread->tlist));
|
||||
/* 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]),
|
||||
&(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_NAME_MAX, thread->name, thread->current_priority));
|
||||
|
|
Loading…
Reference in New Issue