Page 1 of 1

[SOLVED] Software task switching, interrupts remain disabled

Posted: Thu Dec 13, 2012 12:11 pm
by alix
Hello,

I have the following code for switching between tasks

Code: Select all

void switch_task (register_t *regs)
{
   __memcpy (&current_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]);
}
and the __switch_task function

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
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.

Re: Software task switching, interrupts remain disabled

Posted: Thu Dec 13, 2012 12:23 pm
by bluemoon
Without looking at the code I guess you don't EOI since you switched task.

Re: Software task switching, interrupts remain disabled

Posted: Thu Dec 13, 2012 12:30 pm
by alix
Thanks very much, yes my EOI was called after the handler. Now everything seems to be fine.