Information about create_only and open_or_create

Hi, I am working on shared memory. I am successful in using it but I am trying to optimize my code. I just want to know the differences between create_only and open_or_create. As far as i know, create_only creates the shared memory with given size, while open_or_create can open and create both. But If I use open_or_create instead of create-only, i am getting interprocess exception. Why? Please help. Thanks in advance. -- View this message in context: http://www.nabble.com/Information-about-create_only-and-open_or_create-tp259... Sent from the Boost - Users mailing list archive at Nabble.com.

Hi, I am working on shared memory. I am successful in using it but I am trying to optimize my code. I just want to know the differences between create_only and open_or_create. As far as i know, create_only creates the shared memory with given size, while open_or_create can open and create both. But If I use open_or_create instead of create-only, i am getting interprocess exception. Why? Please help. Thanks in advance. manish4gupta wrote:
Hi,
I am working on shared memory. I am successful in using it but I am trying to optimize my code. I just want to know the differences between create_only and open_or_create. As far as i know, create_only creates the shared memory with given size, while open_or_create can open and create both. But If I use open_or_create instead of create-only, i am getting interprocess exception. Why? Please help. Thanks in advance.
-- View this message in context: http://www.nabble.com/Information-about-create_only-and-open_or_create-tp259... Sent from the Boost - Users mailing list archive at Nabble.com.

2009/10/22 manish4gupta
I am working on shared memory. I am successful in using it but I am trying
Please provide more detailed information about your problem. Add a short (compilable) example demonstrating the problem, including the complete error message. Also provide information about your operating system, compiler, etc... Don't just post the same question again. Thanks. Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3

Process1.cpp
#include
2009/10/22 manish4gupta
: I am working on shared memory. I am successful in using it but I am trying
Please provide more detailed information about your problem. Add a short (compilable) example demonstrating the problem, including the complete error message. Also provide information about your operating system, compiler, etc...
Don't just post the same question again. Thanks.
Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/Information-about-create_only-and-open_or_create-tp259... Sent from the Boost - Users mailing list archive at Nabble.com.

managed_shared_memory segment(open_or_create,MySharedMemory, 999999999);
This is not a valid mode you pass to managed_shared_memory. Read man 2 open. And btw, there is a trim() function already in boost string_algo: http://www.boost.org/doc/libs/1_40_0/doc/html/boost/algorithm/trim.html But it doesn't behave exactly like your implementation. If you really intended that behaviour you could use: http://www.boost.org/doc/libs/1_40_0/doc/html/boost/algorithm/replace_all.ht... Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3

But i am getting the following defintion for the function. basic_managed_shared_memory (open_or_create_t open_or_create, const char *name, std::size_t size, const void *addr = 0) : base_t() , base2_t(open_or_create, name, size, read_write, addr, create_open_func_t(get_this_pointer(), detail::DoOpenOrCreate)) {} I think i am using in same way. Can u suggest how it can be used in defferent way.Thanks in advance. Christoph Gysin-3 wrote:
managed_shared_memory segment(open_or_create,MySharedMemory, 999999999);
This is not a valid mode you pass to managed_shared_memory. Read man 2 open.
And btw, there is a trim() function already in boost string_algo: http://www.boost.org/doc/libs/1_40_0/doc/html/boost/algorithm/trim.html
But it doesn't behave exactly like your implementation. If you really intended that behaviour you could use: http://www.boost.org/doc/libs/1_40_0/doc/html/boost/algorithm/replace_all.ht...
Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/Information-about-create_only-and-open_or_create-tp259... Sent from the Boost - Users mailing list archive at Nabble.com.

But i am getting the following defintion for the function.
Sorry, I wasn't reading your post correctly. I was referring to
open_shared_object.
For me, the following stripped down example throws already:
#include

I am running on Itanium IA64. Still if i keep the size 9999999, still there will be error. On Mon, Oct 26, 2009 at 10:58 AM, Christoph Gysin < christoph.gysin@fr33z3.org> wrote:
But i am getting the following defintion for the function.
Sorry, I wasn't reading your post correctly. I was referring to open_shared_object.
For me, the following stripped down example throws already:
#include
using namespace boost::interprocess; int main (int argc, char *argv[]) { managed_shared_memory segment(open_or_create, "MySharedMemory", 999999999); } $ ./a.out terminate called after throwing an instance of 'boost::interprocess::interprocess_exception' what(): Aborted
This is due to an illegal size for the shared memory area on my plattform (linux):
$ cat /proc/sys/kernel/shmmax 33554432
Shouldn't the exception report "invalid argument" if size > SHMMAX?
manish4gupta, what system are you running the example on?
Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Manish Gupta Bioinformatics Software Developer Synamatix Sdn Bhd. Kulalumpur, Malaysia
participants (3)
-
Christoph Gysin
-
Manish Kumar
-
manish4gupta