OSDev.org

The Place to Start for Operating System Developers
It is currently Mon May 20, 2024 1:34 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: hard time managing multiple address spaces
PostPosted: Mon Apr 06, 2020 9:13 am 
Offline

Joined: Mon Apr 06, 2020 5:06 am
Posts: 3
I am trying to implement multitasking for my kernel but I ran into a problem,
After reading about multitasking I figured that I need to do the following in order to create "threads" in my kernel.

1. Create a new address space for the new thread.
2. Copy all the pages in the old address space into the new one (as in copy the page entry in the tables which means they share memory).
3. Find the pages for the stack and swap them out for new clean pages.
4. Clone the current stack with memcpy into the new clean pages.
5. And swap to the new address space.

Right now my kernel uses recursive mapping to manage the virtual memory but this is a big problem for what I am trying to do, I can't access any of the page tables in the new address space because it isn't self-mapped.

So after a bit of thinking i came up with some solutions that might work.

The first option is to save a struct with the physical and virtual memory of the page and use some kind of temp page to map page dirs and tables I need to modified, but this will cost a lot of memory.
And the second one is using the same page tables for all kernel address spaces beside two one for self-mapping and one for the stack, but here we wast a lot of the virtual address space for just a stack.

So I am stuck cause I don't want to use any of my options because of their big draw backs, any tips ideas (or even your own experience in the matter) on how to implement that would be grate.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 27 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