kernel and tasks
Posted: Mon Apr 19, 2004 6:35 am
Hello.
Im working on a kernel and now i want to add multitasking support for it. I haven't decided yet which type of switch to use (hw or sw). But I have some questions about the memory management for the tasks.
First I want to ask about the stack. Is it right that I have one kernel mode (ring 0) stack, and a stack for each user task (ring 3)?
Right now the kernel has not a good address for the stack, I'll fix that, but should I use a stack segment? I seems to work fine without one.
But if I understand it right with the stacks the kernel needs to manage the tasks and their stacks in memory. How about putting the task's stack right after the task's code in memory?
If I got that right I need to allocate memory for the tasks and put them there. Right now I have kmalloc/kfree functions which allocates memory from a static heap (not good, but will fix that in the future).
This confuses me, should I use kmalloc/kfree for allocating memory for my tasks? Then I can have the heap take all physical memory. but... I don't even know exactly what a heap is But if I would guess, the heap is used for kernel structures and stuff, and the task's memory should be handled on some other way than kmalloc/kfree.
Sorry for so much questions, but I would be glad if someone would help me get a better understanding on this.
Thanks!
/Norton
Im working on a kernel and now i want to add multitasking support for it. I haven't decided yet which type of switch to use (hw or sw). But I have some questions about the memory management for the tasks.
First I want to ask about the stack. Is it right that I have one kernel mode (ring 0) stack, and a stack for each user task (ring 3)?
Right now the kernel has not a good address for the stack, I'll fix that, but should I use a stack segment? I seems to work fine without one.
But if I understand it right with the stacks the kernel needs to manage the tasks and their stacks in memory. How about putting the task's stack right after the task's code in memory?
If I got that right I need to allocate memory for the tasks and put them there. Right now I have kmalloc/kfree functions which allocates memory from a static heap (not good, but will fix that in the future).
This confuses me, should I use kmalloc/kfree for allocating memory for my tasks? Then I can have the heap take all physical memory. but... I don't even know exactly what a heap is But if I would guess, the heap is used for kernel structures and stuff, and the task's memory should be handled on some other way than kmalloc/kfree.
Sorry for so much questions, but I would be glad if someone would help me get a better understanding on this.
Thanks!
/Norton