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.
You're still setting esp to 0. Re-read my previous posts. This is probably the problem.
You didn't post the latest version of your stack_data struct, so I can't tell if EIP is in the right place or not. It pays to consult the Intel manuals...
Top three reasons why my OS project died:
Too much overtime at work
Got married
My brain got stuck in an infinite loop while trying to design the memory manager
struct stack_data
{
unsigned int gs;
unsigned int fs;
unsigned int es;
unsigned int ds;
unsigned int edi;
unsigned int esi;
unsigned int ebp;
unsigned int esp;
unsigned int ebx;
unsigned int edx;
unsigned int ecx;
unsigned int eax;
unsigned int eip;
unsigned int cs;
unsigned int eflags;
};
struct task_data
{
char name[33];
struct stack_data *stack;
unsigned int ss;
unsigned int kstack;
unsigned int ustack;
unsigned int time;
unsigned int priority;
};
Colonel Kernel wrote:According to the way that pusha works (remember, the Intel manuals are your friend), the value of ESP that gets pushed is the value that ESP was before pushing EAX (that is, before the pusha instruction began executing). So, it should point to the eip field of the stack_data struct.
Top three reasons why my OS project died:
Too much overtime at work
Got married
My brain got stuck in an infinite loop while trying to design the memory manager
Why the heck are you allocating yet another stack? You already allocated it at the beginning of make_task()! Did my suggestion not make any sense?
p.s. whats your code look like???
I haven't implemented task creation yet, so my code is exactly what I'm suggesting to you in this thread.
You need to take a step back and really try to understand what you're doing. Otherwise, you're operating on pure superstition and you're not going to get anywhere. Read the Intel Manuals. Grab a good book (the Minix book includes source, and is worth reading). Just chill out and stop making random guesses.
But first, try my suggestion and tell me if it works.
Top three reasons why my OS project died:
Too much overtime at work
Got married
My brain got stuck in an infinite loop while trying to design the memory manager
nm, I'm mental. :-[ POPA doesn't pop ESP; it just ignores it. And EBP will get set up by your task function as soon as it starts running. So, you should be able to leave both of them zero. As for why it doesn't work, now I'm stumped.
BTW, are you trying to run your tasks in ring 0 or ring 3? I have assumed up until now that you want them to run in ring 0, since you set CS to point to the kernel code segment...
<edit>
When you get the invalid opcode fault, is it possible to see what the value of EIP was when the fault was raised?
</edit>
Top three reasons why my OS project died:
Too much overtime at work
Got married
My brain got stuck in an infinite loop while trying to design the memory manager
ok, i have found one problem my hlt(); was doing something weird and making invaled opcode. but that didn't solve any thing, it still only gets 1 timer IRQ, the system is still running but its like the timer gets disabled???
p.s. hopefully I get a sourceforge site, so you can look at source there so i dont have to post my entire kernel ;D
GLneo wrote:but that didn't solve any thing, it still only gets 1 timer IRQ, the system is still running but its like the timer gets disabled???
What does your timer IRQ handler do? Mine currently does absolutely nothing (apart from sending the EOI), and I get the same behaviour as you, presumably because the handler needs to send some kind of acknowledgement to the PIT before another timer IRQ will fire. I haven't looked into it yet.
Either way, I'd say your problems with task switching are over (for now).
Top three reasons why my OS project died:
Too much overtime at work
Got married
My brain got stuck in an infinite loop while trying to design the memory manager
your right, it finaly did a switch ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D but only one, well that is becouse only one irq fires, but still the switch to task1() worked!!! ;D