mirror of
https://github.com/drasko/codezero.git
synced 2026-01-14 11:53:15 +01:00
Fixes to the scheduler timeslice management.
One is related to the time distribution when a new child is created. If the parent has one tick left, then both child and parent received zero tick. When combined with current_irq_nest_count = 1 voluntary_preempt = 0 values, this caused the scheduler from being invoked. Second is related to the overall time distribution. When a thread runs out of time, its new time slice is calculated by the below formula: new_timeslice = (thread_prio * SCHED_TICKS) / total_prio If we consider total_prio is equal to the sum of the priorities of all the threads in the system, it imposes a problem of getting zero tick. In the new scenario, total_prio is equal to the priority types in the system so it is fixed. Every thread gets a timeslice in proportion of their priorities. Thus, there is no risk of taking zero tick.
This commit is contained in:
committed by
Bahadir Balban
parent
90cfaca7a2
commit
2571dabc18
@@ -17,6 +17,7 @@
|
||||
#define TASK_PRIO_SERVER 6
|
||||
#define TASK_PRIO_NORMAL 4
|
||||
#define TASK_PRIO_LOW 2
|
||||
#define TASK_PRIO_TOTAL 30
|
||||
|
||||
/* Ticks per second, try ticks = 1000 + timeslice = 1 for regressed preemption test. */
|
||||
#define SCHED_TICKS 100
|
||||
@@ -25,7 +26,7 @@
|
||||
* A task can run continuously at this granularity,
|
||||
* even if it has a greater total time slice.
|
||||
*/
|
||||
#define SCHED_GRANULARITY SCHED_TICKS/10
|
||||
#define SCHED_GRANULARITY SCHED_TICKS/50
|
||||
|
||||
static inline struct ktcb *current_task(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user