Skip navigation.
Home
The QNX Community Portal

View topic - align physical memory

align physical memory

anything that doesn't fit to other groups.

align physical memory

Postby phungha2511 » Tue Mar 15, 2011 6:42 am

Hi every one,

I would like to get physical address of share memory. My code likes this:
1. Create a share memory using shm_open();
2. Using shm_ctl() to set attribute of that share memory
3. Map memory object by mmap();
4. Get physical address of this memory by mem_offset();

My problem is that, the physical address is not align to the size of memory. How can I align this physical address?

For example:
- memsize = 4KBytes, the physical address must be multiples of 0x1000
- memsize = 8MBytes, the physical address must be multiples of 0x800000

Thanks.

Zodiac
phungha2511
New Member
 
Posts: 3
Joined: Thu May 27, 2010 6:20 am

RE: align physical memory

Postby mario » Tue Mar 15, 2011 12:46 pm

You cannot. mmap/allocated bigger then you need and compensate yourself by setting the pointer to a multiple of what you need. That will waste memory but I don't know of any other way.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby phungha2511 » Wed Mar 16, 2011 2:08 am

Thanks Mario :)
phungha2511
New Member
 
Posts: 3
Joined: Thu May 27, 2010 6:20 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 2 guests