[SOLVED] Software task switching, interrupts remain disabled
Posted: Thu Dec 13, 2012 12:11 pm
Hello,
I have the following code for switching between tasks
and the __switch_task function
However when i switch task the first time, no more timer ticks and i'm not able to find out why. Any help will be greatly appreciated.
I have the following code for switching between tasks
Code: Select all
void switch_task (register_t *regs)
{
__memcpy (¤t_task->regs[0], regs, sizeof (register_t));
foreach(node, tasks)
{
task_t *t = (task_t*)node->value;
if (t == current_task)
{
if (node->next)
current_task = (task_t*)node->next->value;
else
current_task = tasks->tail->value;
break;
}
}
__switch_task (current_task->regs[0]);
}
Code: Select all
[GLOBAL __switch_task]
__switch_task:
add esp, 4
pop ds
pop es
pop fs
pop gs
popa
add esp, 8 ;Get rid of int_no, err_code
push eax
add esp, 12
pop eax ; Get Get the eflags
or eax, 0x200
push eax ; Push eax again
sub esp, 12
pop eax
iretd