the idle priority doesn't longer possess an own runqueue
only the idle task uses this priority class
This commit is contained in:
parent
4c9855c83a
commit
296e8e98f4
2 changed files with 54 additions and 47 deletions
|
@ -40,7 +40,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_PRIO 32
|
||||
#define MAX_PRIO 31
|
||||
#define REALTIME_PRIO 31
|
||||
#define HIGH_PRIO 16
|
||||
#define NORMAL_PRIO 8
|
||||
|
|
|
@ -129,13 +129,13 @@ static void finish_task_switch(void)
|
|||
spinlock_lock(&runqueues[core_id].lock);
|
||||
if ((old = runqueues[core_id].old_task) != NULL) {
|
||||
prio = old->prio;
|
||||
if (!runqueues[core_id].queue[prio].first) {
|
||||
if (!runqueues[core_id].queue[prio-1].first) {
|
||||
old->prev = NULL;
|
||||
runqueues[core_id].queue[prio].first = runqueues[core_id].queue[prio].last = old;
|
||||
runqueues[core_id].queue[prio-1].first = runqueues[core_id].queue[prio-1].last = old;
|
||||
} else {
|
||||
old->prev = runqueues[core_id].queue[prio].last;
|
||||
runqueues[core_id].queue[prio].last->next = old;
|
||||
runqueues[core_id].queue[prio].last = old;
|
||||
old->prev = runqueues[core_id].queue[prio-1].last;
|
||||
runqueues[core_id].queue[prio-1].last->next = old;
|
||||
runqueues[core_id].queue[prio-1].last = old;
|
||||
}
|
||||
runqueues[core_id].old_task = NULL;
|
||||
runqueues[core_id].prio_bitmap |= (1 << prio);
|
||||
|
@ -242,7 +242,7 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg, uint8_t
|
|||
return -EINVAL;
|
||||
if (BUILTIN_EXPECT(prio == IDLE_PRIO, 0))
|
||||
return -EINVAL;
|
||||
if (BUILTIN_EXPECT(prio >= MAX_PRIO, 0))
|
||||
if (BUILTIN_EXPECT(prio > MAX_PRIO, 0))
|
||||
return -EINVAL;
|
||||
|
||||
spinlock_irqsave_lock(&table_lock);
|
||||
|
@ -282,15 +282,22 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg, uint8_t
|
|||
// add task in the runqueue
|
||||
spinlock_lock(&runqueues[core_id].lock);
|
||||
runqueues[core_id].prio_bitmap |= (1 << prio);
|
||||
if (!runqueues[core_id].queue[prio].first) {
|
||||
kprintf("prio %d %p\n", prio, runqueues[core_id].queue[prio-1].first);
|
||||
if (!runqueues[core_id].queue[prio-1].first) {
|
||||
task_table[i].prev = NULL;
|
||||
runqueues[core_id].queue[prio].first = task_table+i;
|
||||
runqueues[core_id].queue[prio].last = task_table+i;
|
||||
kputs("A");
|
||||
runqueues[core_id].queue[prio-1].first = task_table+i;
|
||||
kputs("B");
|
||||
runqueues[core_id].queue[prio-1].last = task_table+i;
|
||||
kputs("C");
|
||||
task_table[i].next = NULL;
|
||||
} else {
|
||||
task_table[i].prev = runqueues[core_id].queue[prio].last;
|
||||
runqueues[core_id].queue[prio].last->next = task_table+i;
|
||||
runqueues[core_id].queue[prio].last = task_table+i;
|
||||
kputs("D");
|
||||
task_table[i].prev = runqueues[core_id].queue[prio-1].last;
|
||||
kputs("E");
|
||||
runqueues[core_id].queue[prio-1].last->next = task_table+i;
|
||||
kputs("F");
|
||||
runqueues[core_id].queue[prio-1].last = task_table+i;
|
||||
task_table[i].next = NULL;
|
||||
}
|
||||
spinlock_unlock(&runqueues[core_id].lock);
|
||||
|
@ -364,15 +371,15 @@ int sys_fork(void)
|
|||
// add task in the runqueue
|
||||
spinlock_lock(&runqueues[core_id].lock);
|
||||
runqueues[core_id].prio_bitmap |= (1 << parent_task->prio);
|
||||
if (!runqueues[core_id].queue[parent_task->prio].first) {
|
||||
if (!runqueues[core_id].queue[parent_task->prio-1].first) {
|
||||
task_table[i].prev = NULL;
|
||||
runqueues[core_id].queue[parent_task->prio].first = task_table+i;
|
||||
runqueues[core_id].queue[parent_task->prio].last = task_table+i;
|
||||
runqueues[core_id].queue[parent_task->prio-1].first = task_table+i;
|
||||
runqueues[core_id].queue[parent_task->prio-1].last = task_table+i;
|
||||
task_table[i].next = NULL;
|
||||
} else {
|
||||
task_table[i].prev = runqueues[core_id].queue[parent_task->prio].last;
|
||||
runqueues[core_id].queue[parent_task->prio].last->next = task_table+i;
|
||||
runqueues[core_id].queue[parent_task->prio].last = task_table+i;
|
||||
task_table[i].prev = runqueues[core_id].queue[parent_task->prio-1].last;
|
||||
runqueues[core_id].queue[parent_task->prio-1].last->next = task_table+i;
|
||||
runqueues[core_id].queue[parent_task->prio-1].last = task_table+i;
|
||||
task_table[i].next = NULL;
|
||||
}
|
||||
spinlock_unlock(&runqueues[core_id].lock);
|
||||
|
@ -442,7 +449,7 @@ int create_kernel_task(tid_t* id, entry_point_t ep, void* args, uint8_t prio)
|
|||
kernel_args->func = ep;
|
||||
kernel_args->args = args;
|
||||
|
||||
if (prio >= MAX_PRIO)
|
||||
if (prio > MAX_PRIO)
|
||||
prio = NORMAL_PRIO;
|
||||
|
||||
return create_task(id, kernel_entry, kernel_args, prio);
|
||||
|
@ -861,15 +868,15 @@ int wakeup_task(tid_t id)
|
|||
|
||||
spinlock_lock(&runqueues[core_id].lock);
|
||||
// add task to the runqueue
|
||||
if (!runqueues[core_id].queue[prio].last) {
|
||||
runqueues[core_id].queue[prio].last = runqueues[core_id].queue[prio].first = task;
|
||||
if (!runqueues[core_id].queue[prio-1].last) {
|
||||
runqueues[core_id].queue[prio-1].last = runqueues[core_id].queue[prio-1].first = task;
|
||||
task->next = task->prev = NULL;
|
||||
runqueues[core_id].prio_bitmap |= (1 << prio);
|
||||
} else {
|
||||
task->prev = runqueues[core_id].queue[prio].last;
|
||||
task->prev = runqueues[core_id].queue[prio-1].last;
|
||||
task->next = NULL;
|
||||
runqueues[core_id].queue[prio].last->next = task;
|
||||
runqueues[core_id].queue[prio].last = task;
|
||||
runqueues[core_id].queue[prio-1].last->next = task;
|
||||
runqueues[core_id].queue[prio-1].last = task;
|
||||
}
|
||||
spinlock_unlock(&runqueues[core_id].lock);
|
||||
}
|
||||
|
@ -913,16 +920,16 @@ int block_current_task(void)
|
|||
task_table[id].prev->next = task_table[id].next;
|
||||
if (task_table[id].next)
|
||||
task_table[id].next->prev = task_table[id].prev;
|
||||
if (runqueues[core_id].queue[prio].first == task_table+id)
|
||||
runqueues[core_id].queue[prio].first = task_table[id].next;
|
||||
if (runqueues[core_id].queue[prio].last == task_table+id) {
|
||||
runqueues[core_id].queue[prio].last = task_table[id].prev;
|
||||
if (!runqueues[core_id].queue[prio].last)
|
||||
runqueues[core_id].queue[prio].last = runqueues[core_id].queue[prio].first;
|
||||
if (runqueues[core_id].queue[prio-1].first == task_table+id)
|
||||
runqueues[core_id].queue[prio-1].first = task_table[id].next;
|
||||
if (runqueues[core_id].queue[prio-1].last == task_table+id) {
|
||||
runqueues[core_id].queue[prio-1].last = task_table[id].prev;
|
||||
if (!runqueues[core_id].queue[prio-1].last)
|
||||
runqueues[core_id].queue[prio-1].last = runqueues[core_id].queue[prio-1].first;
|
||||
}
|
||||
|
||||
// No valid task in queue => update prio_bitmap
|
||||
if (!runqueues[core_id].queue[prio].first)
|
||||
if (!runqueues[core_id].queue[prio-1].first)
|
||||
runqueues[core_id].prio_bitmap &= ~(1 << prio);
|
||||
|
||||
spinlock_unlock(&runqueues[core_id].lock);
|
||||
|
@ -959,16 +966,16 @@ int set_timer(uint64_t deadline)
|
|||
curr_task->prev->next = curr_task->next;
|
||||
if (curr_task->next)
|
||||
curr_task->next->prev = curr_task->prev;
|
||||
if (runqueues[core_id].queue[prio].first == curr_task)
|
||||
runqueues[core_id].queue[prio].first = curr_task->next;
|
||||
if (runqueues[core_id].queue[prio].last == curr_task) {
|
||||
runqueues[core_id].queue[prio].last = curr_task->prev;
|
||||
if (!runqueues[core_id].queue[prio].last)
|
||||
runqueues[core_id].queue[prio].last = runqueues[core_id].queue[prio].first;
|
||||
if (runqueues[core_id].queue[prio-1].first == curr_task)
|
||||
runqueues[core_id].queue[prio-1].first = curr_task->next;
|
||||
if (runqueues[core_id].queue[prio-1].last == curr_task) {
|
||||
runqueues[core_id].queue[prio-1].last = curr_task->prev;
|
||||
if (!runqueues[core_id].queue[prio-1].last)
|
||||
runqueues[core_id].queue[prio-1].last = runqueues[core_id].queue[prio-1].first;
|
||||
}
|
||||
|
||||
// No valid task in queue => update prio_bitmap
|
||||
if (!runqueues[core_id].queue[prio].first)
|
||||
if (!runqueues[core_id].queue[prio-1].first)
|
||||
runqueues[core_id].prio_bitmap &= ~(1 << prio);
|
||||
|
||||
// add task to the timer queue
|
||||
|
@ -1046,15 +1053,15 @@ void scheduler(void)
|
|||
prio = task->prio;
|
||||
|
||||
// add task to the runqueue
|
||||
if (!runqueues[core_id].queue[prio].first) {
|
||||
runqueues[core_id].queue[prio].last = runqueues[core_id].queue[prio].first = task;
|
||||
if (!runqueues[core_id].queue[prio-1].first) {
|
||||
runqueues[core_id].queue[prio-1].last = runqueues[core_id].queue[prio-1].first = task;
|
||||
task->next = task->prev = NULL;
|
||||
runqueues[core_id].prio_bitmap |= (1 << prio);
|
||||
} else {
|
||||
task->prev = runqueues[core_id].queue[prio].last;
|
||||
task->prev = runqueues[core_id].queue[prio-1].last;
|
||||
task->next = NULL;
|
||||
runqueues[core_id].queue[prio].last->next = task;
|
||||
runqueues[core_id].queue[prio].last = task;
|
||||
runqueues[core_id].queue[prio-1].last->next = task;
|
||||
runqueues[core_id].queue[prio-1].last = task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1076,13 +1083,13 @@ void scheduler(void)
|
|||
runqueues[core_id].old_task = curr_task;
|
||||
}
|
||||
|
||||
curr_task = per_core(current_task) = runqueues[core_id].queue[prio].first;
|
||||
curr_task = per_core(current_task) = runqueues[core_id].queue[prio-1].first;
|
||||
curr_task->status = TASK_RUNNING;
|
||||
|
||||
// remove new task from queue
|
||||
runqueues[core_id].queue[prio].first = curr_task->next;
|
||||
runqueues[core_id].queue[prio-1].first = curr_task->next;
|
||||
if (!curr_task->next) {
|
||||
runqueues[core_id].queue[prio].last = NULL;
|
||||
runqueues[core_id].queue[prio-1].last = NULL;
|
||||
runqueues[core_id].prio_bitmap &= ~(1 << prio);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue