|
Boost Users : |
From: Andrea Carbone (andrea.carbone_at_[hidden])
Date: 2006-10-21 06:46:56
Hello Ion,
I implemented successfully a program to delivery grabbed images to
clients for display purposes ...
Really fine ...
But it seems to me that the remove method doesn't work.
For example after killing the grabber process and I open again
a Gui to display images, no (ipc) exceptions are thrown and the gui
displays the last grabbed image.
The process that grabs, before quitting calls:
shared_memory_object::remove(mem_obj_tag.c_str());
(the shmem was created with open_or_create)
and the process that reads opens the shared memory in read_only mode.
sincerely,
andrea
Ion Gaztañaga wrote:
> Hi Andrea,
>
>> 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.
>
> Ok.
>
>> 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);
>
> Because the shared memory segment is not a trivial shm_open + mmap-like
> shared memory. It has dynamic allocation, a named parameter index
> type... so it wastes memory. The size passed in open is the shared
> memory size (well, more or less). Each allocate() call needs to keep
> track of the allocated size, to be able to deallocate it when the user
> calls deallocate().
>
> In short, there is no way to know beforehand how much space it will be
> wasted in bookkeeping, since it depends on the number of allocations,
> the alignment, the number of named parameters, their length, the type of
> index...
>
> If you need a raw, classic shared memory, I would recommend you to use
> Boost.Interprocess:
>
> http://boost-consulting.com/vault/index.php?&direction=0&order=&directory=Concurrent%20Programming
>
> Interprocess is the official Boost name for Shmem. I surely will remove
> Shmem from the vault soon because I want people to use Interprocess. In
> interprocess you can create a classic shared memory segment like this:
>
> http://tinyurl.com/z5gyn
>
> Regards,
>
> Ion
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