Page 1 of 1
Multitasking
Posted: Tue Sep 23, 2003 12:05 pm
by Neo
How do u go about trying to implement multitasking.Any help appreciated. Right now all i have is a kernel that prints a string and has a few interrupts.
Re:Multitasking
Posted: Tue Sep 23, 2003 2:07 pm
by mr. xsism
I would suggest you get your memory manager so that it can at least allocate pages. You will need PIC routines and interrupt setup for timer/task scheduler. I am working on tasking right now. Just basically save all regs,segments,eip,and load the next task's data. i'll write a short a simple tutorial on basic tasking soon.
Regards,
mr. xsism
Re:Multitasking
Posted: Tue Sep 23, 2003 3:29 pm
by nullify
Actually, you don't /need/ to use the system timer for simply testing context switches. You can just hook onto an unused interrupt (e.g. 40h) and have each thread explicity call the scheduler (INT 0x40). You'll probably want the scheduler to run at regular intervals by the end anyway, so if you do have the system timer worked out already I see no harm in using it.
Re:Multitasking
Posted: Tue Sep 23, 2003 10:12 pm
by bkilgore
When I was first testing my task-switching code I didn't have my timer running yet, and I didn't really want the system switching the tasks frequently anyways until I got it working, so I used the keyboard handler instead. Basically I made it so pressing Ctrl-1 would switch to the next task in the list, and Ctrl-2 would kill the current task. This made it easy for me to manually test out my code until I got it working as expected, and then I could tie it into the timer to add preemptive switching.
Re:Multitasking
Posted: Wed Sep 24, 2003 11:25 am
by Neo
Yeah what i mean is i dont have any memory manager ? how do i go about creating one
Re:Multitasking
Posted: Wed Sep 24, 2003 11:30 am
by mr. xsism
Just create some sort of scheme that keeps track of whether a page is free or not. I use the AVAIL bits in each Page Table entry. Yo ualso have to map out at least 1 Page directory with at least one PDE(page dir entry) which is a Page table. A pagetable points to pages. After you have your code mapped out, where ever that is, load your PD into CR3. Try osdever.net. We have a couple MM tuts. We also have tim robinson's.
Regards dude,
mr. xsism