|
Boost Users : |
From: Andrea Carbone (andrea.carbone_at_[hidden])
Date: 2006-10-09 13:05:18
Hello dear boost users,
I am trying to use the shmem library for the first time.
The domain of the application is centered on the passing of image frames
from process that acquires the images to the client process via a local
shared memory segment.
In short, nothing really complicated.
A synchronized writer/reader process.
I started from looking at processA/processB example in the example
directory.
I am using boost 1.33.1 and shmem 0.93 (the latest available from boost
vault).
If I open the segment with the exact number of bytes needed:
> const int memsize = 320*240;
> //Create shared memory
> if(!segment.open_or_create(shMemName, memsize)){
> std::cout << "error creating shared memory\n";
> return -1;
> };
Then I cannot use:
> unsigned char* uchar_ptr = (unsigned char*)segment.allocate(num_elements);
with num_elements equal to the memsize.
I see that there is need for an extra memory space to pass as second
argument to the open() function... (for example 320*240+1024) ...
How can I know in advance how many bytes are necessary to allocate the
space actually needed?
For instance, what is the difference between the size in open(..) and
allocate(..)?
In this case I just need a raw_memory segment ....
In more complex cases?
Is there some rule of thumb?
Andrea Carbone
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net