[SOLVED] Software task switching, interrupts remain disabled

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
alix
Posts: 12
Joined: Tue Nov 13, 2012 3:56 pm

[SOLVED] Software task switching, interrupts remain disabled

Post 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.
Last edited by alix on Thu Dec 13, 2012 12:30 pm, edited 1 time in total.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Software task switching, interrupts remain disabled

Post by bluemoon »

Without looking at the code I guess you don't EOI since you switched task.
User avatar
alix
Posts: 12
Joined: Tue Nov 13, 2012 3:56 pm

Re: Software task switching, interrupts remain disabled

Post by alix »

Thanks very much, yes my EOI was called after the handler. Now everything seems to be fine.
Post Reply