multitasking

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
Fukuda

multitasking

Post by Fukuda »

Im trying to implement multitasking for 2 weeks but I can not managed to implement it successfully. After enabling scheduling mechanism, my os restarts in bochs. I can not find what is wrong. Im adding my taskmanger code. Ill be happy if someone examines it.

[attachment deleted by admin]
Ozguxxx

Re:multitasking

Post by Ozguxxx »

A very first thing is that:

Code: Select all

    task[TotalTaskNumber].TaskTSS.esp = (unsigned int) Malloc(0x3000);
Is problematic imo because esp should point to end of stack, I mean stack grows downwards, when you push sth cpu DECREASES esp and movs sth into stack memory. So following might help:

Code: Select all

    task[TotalTaskNumber].TaskTSS.esp = (unsigned int) ( 0x3000 + Malloc(0x3000));
Also I might have missed it but where do you set cr3 register while adding a new task?
I hope these help, good luck.
Fukuda

Re:multitasking

Post by Fukuda »

Yes, u are right about esp. But, do I have to set cr3 register??
Ozguxxx

Re:multitasking

Post by Ozguxxx »

Well in 386 programmer's reference it is told that cr3 is not saved into tss while cpu does a task dispatch so you have to set it manually at the process creation.
Fukuda

Re:multitasking

Post by Fukuda »

Yes, when I load cr3 register my multitasking worked. But the task I load in tr register with tr is not working, but other tasks works well. If I comment out that line, the line I load tr, all my tasks works well. Dont I have to load tr even once? Why is the task I load in tr not working?
Ozguxxx

Re:multitasking

Post by Ozguxxx »

Post Reply