Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Ooops! Few problems with ARM memory management.: Page 1 of 8 (8 Items)
   
Ooops! Few problems with ARM memory management.  
Hi!

I do some experiments with organization of shmem in ARM (xScale pxa255) in QNX 6.3.2.

My current task is to allocate in process as much memory as it's possible.
As soon as application address space in ARM limited by 32M and maximal malloc()able block is about 15Mb, I'm trying my 
best with shared memory.
So reading http://www.qnx.com/developers/docs/6.3.2/neutrino/prog/arm_memory.html
I found that my problem can be solved by using global shmem. :-)

So, I wrote an small test application (see attach).
I have problem with understanding the behavior of QNX under my tests...

My system says:
# pidin info
CPU:ARM Release:6.3.0  FreeMem:46Mb/64Mb BootTime:Jan 01 00:00:00 UTC 1970
Processor1: 1761946886 pxa250 399MHz

1. Lats say I want to allocate 33 Mb of shmem...

When I set SHMEM_SIZE = (33 * 1024 * 1024) my program prints following:
SHMEM allocation test.
shm_open() -> fd = 3 OK
ftruncate() -> r = 0 OK
shm_ctl() -> r = -1 Function not implemented
mmap() -> shmem = 0xFFFFFFFF Not enough memory
Code address:  &main() = 0x00100940
Data address:  &fd     = 0x00101DC4
Stack address: &shmem  = 0x000FFCE0
Shmem address: shmem   = 0xFFFFFFFF
Memsetting... <SIGSEGV>

Shmem block is created but not mapped in address space!
# ls -l /dev/shmem
total 67584
nrwxrwxrwx  3 root      0          34603008 Mar 18 15:53 big_memory_block

Why if it's possible to map (according to docs) more than 32 Mb of physical RAM, it's impossible to map such amount of 
shared RAM?

2. When I set SHMEM_SIZE to 18 or 16 Mb system can't map it globally too!

3. When I set SHMEM_SIZE in 5 Mb memory is mapped successfully, but I see different behavior of C library when I change 
an order of ftruncate() and shm_ctl().
You can see 2 outputs here below.

3a. Case shm_open()->ftruncate()->shm_ctl()->mmap().
SHMEM allocation test.
shm_open() -> fd = 3 OK
ftruncate() -> r = 0 OK
shm_ctl() -> r = -1 Function not implemented
mmap() -> shmem = 0x01800000 OK
Code address:  &main() = 0x00100940
Data address:  &fd     = 0x00101DC4
Stack address: &shmem  = 0x000FFCE0
Shmem address: shmem   = 0x01800000
Memsetting... OK

Result is that memory is mapped locally (0x01800000).

3b. Case shm_open()->shm_ctl()->ftruncate()->mmap().
SHMEM allocation test.
shm_open() -> fd = 3 OK
shm_ctl() -> r = 0 OK
ftruncate() -> r = -1 Invalid argument
mmap() -> shmem = 0x82000000 OK
Code address:  &main() = 0x00100940
Data address:  &fd     = 0x00101DC4
Stack address: &shmem  = 0x000FFCE0
Shmem address: shmem   = 0x82000000
Memsetting... OK

Result is that memory is mapped globally (0x82000000).

Here I have some problem with usage of ftruncate() and shm_ctl() together.

And main question is: want I'm doing wrong when I trying to map big peace of RAM in global address space zone?

Thanks!

PS: Document (see link above) says that it's possible to create up to 63 processes in ARM based system. But this doc 
didn't say that it's absolutely impossible to change this number to 95 or so... What about new option for procnto what 
change this parameter at startup?
For our project it's really critical limitation...

--
AG
Attachment: Compressed file shmem-test.zip 24.69 KB