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
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Multitasking

Post 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.
Only Human
mr. xsism

Re:Multitasking

Post 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
nullify

Re:Multitasking

Post 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.
bkilgore

Re:Multitasking

Post 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.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Multitasking

Post by Neo »

Yeah what i mean is i dont have any memory manager ? how do i go about creating one
Only Human
mr. xsism

Re:Multitasking

Post 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
Post Reply