469,883 Members | 1,053 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,883 developers. It's quick & easy.

pragma value for shared variables

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

Sep 13 '07 #1
3 3574
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
Sep 13 '07 #2
On Sep 13, 4:30 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
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.

Sep 14 '07 #3
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.
Sep 14 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ryang | last post: by
20 posts views Thread by Glenn Venzke | last post: by
8 posts views Thread by gemel | last post: by
5 posts views Thread by Confused ! | last post: by
15 posts views Thread by muttaa | last post: by
debasisdas
reply views Thread by debasisdas | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.