Vijayraj Hada
04/27/2010 8:25 AM
post52869
|
> Hi,
>
> you can do both allocations using mmap(). To allocate physically contiguous
> memory, you must specify flags MAP_PHYS and MAP_ANON and NOFD as the file
> descriptor, so for your buffer descriptors that'd be:
>
> descriptors = mmap( NULL, 256*64*8,
> PROT_READ|PROT_WRITE|PROT_NOCACHE,
> MAP_PHYS|MAP_ANON, NOFD, 0 );
>
> Since mmap allocations are done in full RAM pages of 4k each, you won't need
> to worry about the alignment of your descriptors or your buffers. Even better:
> Your buffers won't need to be allocated physically contiguous, as 2 buffers
> will just fit into one page. So here, a 'simple' allocation is sufficient:
> bufs = mmap( NULL, 256*64*2048,
> PROT_READ|PROT_WRITE|PROT_NOCACHE,
> MAP_ANON, NOFD, 0 );
>
> Hope this helps,
> - Thomas
Hi,
Thank you for fast reply
I looked at the mmap() library function reference. Three are two flags MAP_PRIVATE and MAP_SHARED.
MAP_SHARED
The mapping may be shared by many processes.
MAP_PRIVATE
The mapping is private to the calling process. It allocates system RAM and copies the current object.
1) As I don't want memory space to be shared so definitely I will not use MAP_SHARED.
2) But should I use MAP_PRIVATE? Cause it says, it allocates system RAM and "copies" the current object.
Actually Buffer and buffer-descriptors can be modified by hardware any-time.
Thank You
|
|
|