Using PIT for 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
mrjbom
Member
Member
Posts: 317
Joined: Sun Jul 21, 2019 7:34 am

Using PIT for multitasking

Post by mrjbom »

Hi.
I'm trying to implement preemptive multitasking, for this I'm going to use PIT(irq0) for this task.
I use this article to switch between tasks.
How I'm going to do this, I'll keep some sort of table with processes and their priorities.
While interrupting IRQ0(for example every 50 MS), I will call the task scheduler, which will change the priorities of various tasks and call yeild(), but I don't think that article is particularly suitable for me.
What can you advise me? Can there be any examples? Articles?
Thanks.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Using PIT for multitasking

Post by nexos »

Hello,
From my experience in multitasking, you will want to switch tasks much more often, like several hundred times a seconds. About 3 PIT ticks. The PIT is what I use, it works great. Besides that, it sounds good, but you should only change priorities when a high priority process is taking up too much time. Also, consider having one queue per priority. The tutorial you are looking at is about cooperative multitasking, which is much different. I recommend making it all on your own. You must understand everything, as multitasking is quite complicated. It took me a full month to implement a very simple scheduler! I haven't implemented priorities yet, so can't be much more help. Anyway, it sounds great! Good luck implementing it!
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply