Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > pragma value for shared variables

Reply
Thread Tools

pragma value for shared variables

 
 
Oops-c++
Guest
Posts: n/a
 
      09-13-2007
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

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      09-13-2007
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-lit...t.html#faq-5.9

--
Erik Wikström
 
Reply With Quote
 
 
 
 
Oops-c++
Guest
Posts: n/a
 
      09-14-2007
On Sep 13, 4:30 pm, Erik Wikström <(E-Mail Removed)> 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-lit...t.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.

 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      09-14-2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Global Shared functions, shared variables Imran Aziz ASP .Net 1 08-22-2005 06:43 PM
Shared Public Variables and Shared Methods Joe Fallon ASP .Net 3 07-16-2004 07:11 AM
Re: Class public shared Variables vs. Application Variables in ASP.NET avnrao ASP .Net 0 05-07-2004 05:28 AM
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class. DJ Dev ASP .Net 3 02-08-2004 04:19 PM



Advertisments