pragma value for shared variables

Discussion in 'C++' started by Oops-c++, Sep 13, 2007.

  1. Oops-c++

    Oops-c++ Guest

    All,

    I came to know that, we can define #pragma variables to share values
    between the processes.

    #pragma data_seg(".shared")
    var1
    variable2
    #pragma data_seg()

    Is there are any advantages/disadv. over using file mapping. Can any
    one send me detials or any link which compares or explains about these
    shared variables

    Thanks
    Radha G
     
    Oops-c++, Sep 13, 2007
    #1
    1. Advertising

  2. On 2007-09-13 12:30, Oops-c++ wrote:
    > All,
    >
    > I came to know that, we can define #pragma variables to share values
    > between the processes.
    >
    > #pragma data_seg(".shared")
    > var1
    > variable2
    > #pragma data_seg()
    >
    > Is there are any advantages/disadv. over using file mapping. Can any
    > one send me detials or any link which compares or explains about these
    > shared variables


    A problem with all progma directives is that most or perhaps all of them
    are implementation dependent. That means that compiling the same code
    with another compiler or even just with another version of the same
    compiler might give different results. IIRC a compiler should just
    ignore any pragmas that it does not understand.

    There are an number of different ways to share data between processes,
    which one you should use depends on a lot of things, like which platform
    your program runs on, how much data you need to share, and in which
    manner you need to share it. For better advice explain your needs in a
    group discussing your platform. The FAQ have some suggestions of groups:
    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9

    --
    Erik Wikström
     
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=, Sep 13, 2007
    #2
    1. Advertising

  3. Oops-c++

    Oops-c++ Guest

    On Sep 13, 4:30 pm, Erik Wikström <> wrote:
    > On 2007-09-13 12:30, Oops-c++ wrote:
    >
    > > All,

    >
    > > I came to know that, we can define #pragma variables to share values
    > > between the processes.

    >
    > > #pragma data_seg(".shared")
    > > var1
    > > variable2
    > > #pragma data_seg()

    >
    > > Is there are any advantages/disadv. over using file mapping. Can any
    > > one send me detials or any link which compares or explains about these
    > > shared variables

    >
    > A problem with all progma directives is that most or perhaps all of them
    > are implementation dependent. That means that compiling the same code
    > with another compiler or even just with another version of the same
    > compiler might give different results. IIRC a compiler should just
    > ignore any pragmas that it does not understand.
    >
    > There are an number of different ways to share data between processes,
    > which one you should use depends on a lot of things, like which platform
    > your program runs on, how much data you need to share, and in which
    > manner you need to share it. For better advice explain your needs in a
    > group discussing your platform. The FAQ have some suggestions of groups:http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9
    >
    > --
    > Erik Wikström


    ThanQ Erik. I am working on Windows and *NIX
    environments(Linux,AIX,solaris,HP-UX). I am using shared memory(POSIX-
    on linux,File mapping object on windows) for IPC. The data size that
    shared between the the process is 1-2 kB. Is there any other better
    way to have IPC between processes? Do you know the exclusive IPC
    group? Please send me the details.

    Thanks
    Radha. G.
     
    Oops-c++, Sep 14, 2007
    #3
  4. Oops-c++

    Ian Collins Guest

    Oops-c++ wrote:
    >
    > ThanQ Erik. I am working on Windows and *NIX
    > environments(Linux,AIX,solaris,HP-UX). I am using shared memory(POSIX-
    > on linux,File mapping object on windows) for IPC. The data size that
    > shared between the the process is 1-2 kB. Is there any other better
    > way to have IPC between processes? Do you know the exclusive IPC
    > group? Please send me the details.
    >

    Forget pragmas and use the standard shared memory APIs on you platforms.

    --
    Ian Collins.
     
    Ian Collins, Sep 14, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    3
    Views:
    16,131
    Gandalf
    Feb 8, 2004
  2. avnrao
    Replies:
    0
    Views:
    3,366
    avnrao
    May 7, 2004
  3. Joe Fallon
    Replies:
    3
    Views:
    765
    =?Utf-8?B?Z3V5?=
    Jul 16, 2004
  4. ben
    Replies:
    3
    Views:
    513
    Kevin Spencer
    Nov 15, 2004
  5. Imran Aziz
    Replies:
    1
    Views:
    543
    Stefan
    Aug 22, 2005
Loading...

Share This Page