pragma value for shared variables

O

Oops-c++

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
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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
 
O

Oops-c++

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

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.
 
I

Ian Collins

Oops-c++ said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top