OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 12:49 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: What should be implemented before multitasking?
PostPosted: Thu May 14, 2020 1:31 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 296
Hi.
I want to implement multitasking in my OS, but I don't understand what I need to do before that.
Now I can work work with the keyboard and I have a primitive physical memory manager (divides the memory into pages and allocate the desired number of pages), is this enough to implement kernel multitasking? Or should I do something else?
I think so, but it's better to ask.


Top
 Profile  
 
 Post subject: Re: What should be implemented before multitasking?
PostPosted: Thu May 14, 2020 5:57 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
Very close, you just need to implement interrupt handling. Return from the interrupt with a different set of registers (including the instruction pointer and stack pointer) to what you entered with.

Then, this interrupt could be fired from a timer or manually fired by a thread willing to give up control.

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: What should be implemented before multitasking?
PostPosted: Fri May 15, 2020 12:52 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
I'd say that allocating memory as pages, rather than smaller amounts, is going to be a little wasteful. I'd recommend writing a memory allocator to hand out smaller chunks of (virtual) memory.


Top
 Profile  
 
 Post subject: Re: What should be implemented before multitasking?
PostPosted: Fri May 15, 2020 8:26 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 296
AndrewAPrice wrote:
Very close, you just need to implement interrupt handling. Return from the interrupt with a different set of registers (including the instruction pointer and stack pointer) to what you entered with.

Then, this interrupt could be fired from a timer or manually fired by a thread willing to give up control.


I already have interrupts, I think I need to implement software interrupts somehow. I also need a timer with millisecond accuracy to switch between tasks. But I don't know what kind of watch will help me.


Top
 Profile  
 
 Post subject: Re: What should be implemented before multitasking?
PostPosted: Fri May 15, 2020 1:31 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
I found the PIT very easy to use. It'll fire an interrupt on IRQ0.

_________________
My OS is Perception.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 32 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group