Page 1 of 1

multitasking

Posted: Sat Dec 27, 2003 10:06 am
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]

Re:multitasking

Posted: Sat Dec 27, 2003 11:46 am
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.

Re:multitasking

Posted: Sat Dec 27, 2003 5:13 pm
by Fukuda
Yes, u are right about esp. But, do I have to set cr3 register??

Re:multitasking

Posted: Sat Dec 27, 2003 5:30 pm
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.

Re:multitasking

Posted: Sat Dec 27, 2003 6:04 pm
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?

Re:multitasking

Posted: Sat Dec 27, 2003 11:52 pm
by Ozguxxx