i want to to a simple task switching example but i have a problem while returning to kernel task.
i've done it following these steps :
- i use ltr command to assign the task 0 to the kernel
- i type a command that tell a task (using a jump [task_tss])
- then this task activate a simple scheduler
- the scheduler wait 1 or 3 sconds (while the task is running)
- then do a jump back to the kernel tss
after this last step my kernel hangs, there is no error and no exception ...
can any one tells me what is the problem ???
task switching ??
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:task switching ??
except the fact that 'tss 0' seems a weird idea for the initial loading (the value should at least be a valid TSS selector, though i don't remember what Intel exactly says about using LTR 0...
Re:task switching ??
the value of my tss is not 0 but a gdt entry of an empty tss (0 mean initial task , i placed my scheduler in timer interrupt handler.
i think the problem is that when doing jump to kernel task from timer int handler, this one become blocked !!
i think the problem is that when doing jump to kernel task from timer int handler, this one become blocked !!
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:task switching ??
you made sure the next interrupt will not try to jump to task X while being in task X, of course ...
Re:task switching ??
i've done it but i have the same problem, it seems that after switching back to the kernel (or to another task), the timer handler is no more called after the first switch.
i also tried to do a very simple scheduler : all what it do is to jump back to the kernel if current running task is not the karnel, so first i use a command line to run the task (i'm using a jump to task tss) , the task put a message and next time timer is called it must ruturn to the kernel (using a jump to kernel tss) after returning to the kernel, my stops responding (i checked regiters and i'm sure that the scheduler succecefully returned to the kernel???).
also, i noticed a very strange thing, i booted with xos floppy on a laptop, after task switching (and stop responding), i turned off the laptop (so this one saved the content of its memory so it can restore what it was doing before powered off), after turnin on the laptop, my kernel was running normaly ???
i also tried to do a very simple scheduler : all what it do is to jump back to the kernel if current running task is not the karnel, so first i use a command line to run the task (i'm using a jump to task tss) , the task put a message and next time timer is called it must ruturn to the kernel (using a jump to kernel tss) after returning to the kernel, my stops responding (i checked regiters and i'm sure that the scheduler succecefully returned to the kernel???).
also, i noticed a very strange thing, i booted with xos floppy on a laptop, after task switching (and stop responding), i turned off the laptop (so this one saved the content of its memory so it can restore what it was doing before powered off), after turnin on the laptop, my kernel was running normaly ???
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:task switching ??
could it occur that you're missing one 'outb(0x20,0x20)' in the process ?
that was one of my early mistake when performing the scheduling: if the task_switch transfer execution from an interrupt to something that has not called the scheduler from the same interrupt handler, then it may occur that the PIC doesn't recieve the acknowledge and therefore will not allow further IRQs to make it to the CPU.
The solution is to emit the EOI *before* calling the scheduler when in an interrupt handler ...
that was one of my early mistake when performing the scheduling: if the task_switch transfer execution from an interrupt to something that has not called the scheduler from the same interrupt handler, then it may occur that the PIC doesn't recieve the acknowledge and therefore will not allow further IRQs to make it to the CPU.
The solution is to emit the EOI *before* calling the scheduler when in an interrupt handler ...
Re:task switching ??
so i must do an outb(0x20, 0x20) under timer int handler and before calling scheduler ?
I'll try it.
I'll try it.