I am not able to find the answers to the following questions, please help:

1. Can a program ask for contiguous physical memory, say 8KB of memory from the kernel?
2. If yes, what does kernel do when a program ask for a 8KB chunk? Can the kernel break the 8KB into two 4KB pages? Does these 2 pages allocated have to be contiguous?

Thanks!

01-12-2011

Rubberman

Quote:

Originally Posted by wei

Hi,

I am not able to find the answers to the following questions, please help:

1. Can a program ask for contiguous physical memory, say 8KB of memory from the kernel?
2. If yes, what does kernel do when a program ask for a 8KB chunk? Can the kernel break the 8KB into two 4KB pages? Does these 2 pages allocated have to be contiguous?

Thanks!

I'm not positive about the contiguous part. If you ask for a multiple of pages, the kernel doesn't have to make sure that they are contiguous, but my guess is that if there are two pages contiguous, it will provide them. Since the general page size is, as you noted, 4K, then an 8K request can be any two physical chunks of RAM, but would be contiguous in VM. So, is there a reason for this question, other than the (admirable) desire to increase your knowledge?

01-15-2011

wei

Quote:

Originally Posted by Rubberman

I'm not positive about the contiguous part. If you ask for a multiple of pages, the kernel doesn't have to make sure that they are contiguous, but my guess is that if there are two pages contiguous, it will provide them. Since the general page size is, as you noted, 4K, then an 8K request can be any two physical chunks of RAM, but would be contiguous in VM. So, is there a reason for this question, other than the (admirable) desire to increase your knowledge?

I am wondering if the physical memory is so fragmented, does the OS have to "de-fragment" the physical memory for the purpose of correct operation? or does the physical memory de-fragmentation (if such thing exist) is only for performance purpose?