OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Nov 23, 2020 6:07 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How do I control access to memory via virtual addresses?
PostPosted: Mon Feb 24, 2020 3:03 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 253
Hi.
I write MMU. And I have 4 questions about this.
1. I want to store page addresses and their busy status, for this I will create an array of 1048575 elements, is this correct?
2. I want to search for pages using a loop that will go through all the pages and search for free pages, on a virtual machine iterating over such a large array takes about 0.04-0.07 seconds and it seems to me that this is normal. Is this correct?
3. Upon request of memory, you will be given a virtual address, how can I when queried, the virtual address to give the physical address?
4. Do I use virtual addresses when allocating memory in the kernel?

I am particularly interested in the answer to question 2 and 3.
Thanks.


Top
 Profile  
 
 Post subject: Re: How do I control access to memory via virtual addresses?
PostPosted: Mon Feb 24, 2020 5:03 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3988
Location: Chichester, UK
1. You could use a bitmap instead. This reduces the storage to 1/8th and ...

2. ... increases the speed of searches.

3. You read the value from the appropriate Page Table entry.

4. Yes (although you may need to use physical addresses in some device drivers - e.g. for buffers in a NIC driver).


Top
 Profile  
 
 Post subject: Re: How do I control access to memory via virtual addresses?
PostPosted: Mon Feb 24, 2020 6:39 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 253
iansjack wrote:
1. You could use a bitmap instead. This reduces the storage to 1/8th and ...

2. ... increases the speed of searches.

3. You read the value from the appropriate Page Table entry.

4. Yes (although you may need to use physical addresses in some device drivers - e.g. for buffers in a NIC driver).


With regard to 1 and 2.

1. What kind of bitmap?
2. Using bitmap will increase the speed by 1/8?


Top
 Profile  
 
 Post subject: Re: How do I control access to memory via virtual addresses?
PostPosted: Mon Feb 24, 2020 7:52 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3988
Location: Chichester, UK
Just an array of bytes, each of the 8 bits in the byte corresponding to a physical page. If the bit is set the page is allocated, if not set it is free.

This will reduce memory used to 1/8th of a simple array and will speed searches up by a factor of more than 8. You can efficiently test 32 (or 64 bits) at a time to see if any of them are not set.


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: No registered users and 3 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