OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 3:15 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: What is the relationship between page addressing and virtual
PostPosted: Thu Jan 16, 2020 2:17 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
Hello.
I'm trying to implement dynamic memory allocation(malloc(), free()).

I have already written page frame allocator(code), it can sequentially allocate pages of 4 KB and delete them sequentially(from the last to the first).

Will such a primitive page Manager be enough for my purpose?
If so, what should I do next?


Last edited by mrjbom on Fri Jan 17, 2020 5:57 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: What is the relationship between page addressing and vir
PostPosted: Fri Jan 17, 2020 5:50 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
The page frames containing your kernel are marked "available" in the multiboot memory map. You need to make sure your page frame allocator will not try to allocate those pages.

It's a good idea to translate the multiboot memory map into some other structure, such as a bitmap. This will make it easier to mark your kernel's page frames as allocated. It will also be easier to allocate and free non-sequential pages.

If you want to use virtual memory, you should write your virtual memory manager before you write your dynamic allocator since the dynamic allocator will need to call the virtual memory manager.


Top
 Profile  
 
 Post subject: Re: What is the relationship between page addressing and vir
PostPosted: Fri Jan 17, 2020 6:20 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
Octocontrabass wrote:
The page frames containing your kernel are marked "available" in the multiboot memory map. You need to make sure your page frame allocator will not try to allocate those pages.

It's a good idea to translate the multiboot memory map into some other structure, such as a bitmap. This will make it easier to mark your kernel's page frames as allocated. It will also be easier to allocate and free non-sequential pages.


About page frame allocator: What else do I need to do in my page frame allocator?
1. Make sure that when selecting pages, they do not touch the location where the kernel is located.
What else should I do?


Top
 Profile  
 
 Post subject: Re: What is the relationship between page addressing and vir
PostPosted: Fri Jan 17, 2020 9:49 am 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
mrjbom wrote:
Hello.
I'm trying to implement dynamic memory allocation(malloc(), free()).

I have already written page frame allocator(code), it can sequentially allocate pages of 4 KB and delete them sequentially(from the last to the first).

Will such a primitive page Manager be enough for my purpose?
If so, what should I do next?
- Check how many free pages there are after the block and maybe before it so that you can know if there is enough room to do an expansive realloc or not.

- Make sure that you can distinguish which virtual pages belong to which block if you allocate 2 or 3 distinct contiguous blocks. You can use the AVL field of virtual pages themselves to select the same value 1 to 7 for a same block and make sure to choose a distinct one than the contiguous blocks immediately before and after it.

- Make sure that you can free any memory for a failed allocation (just set up debugging values to emulate not having enough memory at different stages).

- Write code to optimize by just copying physical page entries instead of copying page contents for reallocating your blocks for realloc when they don't fit at their current virtual area, for a huge speed improvement.

- Search for free physical and virtual memory/blocks.

- Try to allocate, resize up and down (reallocate) and free for example a 40-Megabyte block. This one will ultimately allow you to test the real speed of your algorithms. If it takes for example 2 seconds to allocate such a 40MB block, you will have to take some time apart (normally months or a year until you are expert) to find the fastest algorithms you can, to make the interesting investigation about which are the slowest parts of the code and what are the very best ways to accelerate it and exactly why.





Keeping your paging entries consistently at 0 makes it possible that you don't need any additional structures to keep track of what is allocated or free.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 174 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