global instances for managed_shared_memory & message_queue

Dear Boost Grurus,
First of all let me thank you for the huge effort that people like Mr.
Gaztañaga has made to keep boost interprocess improved. It is a really
time-saver API!
I have a very basic question that, despite the large amount of documentation
I've looked, I haven't clarified yet.
I just want to create a global static variables (i.e. instances) for
managed_shared_memory, message_queue, mutex and condition var.
By now I have my app prototype (CGI) is running fine with auto vars, as
appeared in the several examples:
/main() {
...
boost::interprocess::permissions perm;
perm.set_unrestricted();
managed_shared_memory segment(create_only,"MonitorOEE_SharedMemory", 65536,
0, perm);
...
message_queue mq(create_only, "MonitorOEE_MessageQueue", 256,
sizeof(t_QRequest), perm);
...
named_mutex mutex_waiting(create_only, namedMutex, perm);
...
named_condition cdv_wakeup(create_only, namedConditionVar, perm);
...
}/
All segment, mq, cdv_wakeup live in the context of the main function...
Now I want them to be globally accessible from different functions. But I am
not able to. I just partially succeeded creating global pointers to
managed_shared_memory and message_queue. But when constructing object to the
pointer segmentation faults appear...
///Global Declarations
...
static boost::interprocess::message_queue *mq;
static boost::interprocess::managed_shared_memory *segment;
static boost::interprocess::interprocess_mutex mutex_waiting;
static boost::interprocess::interprocess_condition cdv_wakeup;
...
main() {
..
std::auto_ptrboost::interprocess::managed_shared_memoryptr01(new
boost::interprocess::managed_shared_memory(open_only,"MonitorOEE_SharedMemory"));
segment = ptr01.get();
//this seems to work but fails when constructing objects:
IPC_SOAPRequest *pSOAPRequest
=segment->construct

El 25/06/2013 0:45, bb.andersen escribió:
Dear Boost Grurus, I just want to create a global static variables (i.e. instances) for managed_shared_memory, message_queue, mutex and condition var.
I haven't tried that do that. Maybe some OS functions are not prepared to be called before main, or there is some bug preventing this use. Could you provide a full compilable example so I can investigate it more easily? thanks, ion
participants (2)
-
bb.andersen
-
Ion Gaztañaga