by leaving the interrupt handler, we check if an urgent task is ready

if yes, the kernel switchs to this task
This commit is contained in:
Stefan Lankes 2011-09-06 06:46:52 -07:00
parent 3ff872ac31
commit c6339bfd2d
3 changed files with 16 additions and 2 deletions

View file

@ -237,8 +237,7 @@ void irq_handler(struct state *s)
// evaluate only irq status register if int_no = 124
if( s->int_no == 124 ) {
check_workqueues_rem_irq();
}
else {
} else {
check_workqueues();
}
@ -283,4 +282,6 @@ leave_handler:
// timer interrupt?
if ((s->int_no == 32) || (s->int_no == 123))
scheduler(); // switch to a new task
else if ((s->int_no >= 32) && (get_highest_priority() > per_core(current_task)->prio))
scheduler();
}

View file

@ -180,6 +180,14 @@ int sys_execve(const char* fname, char** argv, char** env);
*/
void check_scheduling(void);
/** @brief determine the highest priority of all tasks, which are ready
*
* @return
* - return highest priority
* - if no task is ready, the function returns an invalid value (> MAX_PRIO)
*/
uint32_t get_highest_priority(void);
/** @brief Call to rescheduling
*
* This is a purely assembled procedure for rescheduling

View file

@ -75,6 +75,11 @@ void check_scheduling(void) {
reschedule();
}
uint32_t get_highest_priority(void)
{
return msb(runqueues[CORE_ID].prio_bitmap);
}
int multitasking_init(void) {
if (BUILTIN_EXPECT(task_table[0].status != TASK_IDLE, 0)) {
kputs("Task 0 is not an idle task\n");