Re : Access of a global variable to more than one process ..........
Re : Access of a global variable to more than one process ..........
- Subject: Re : Access of a global variable to more than one process ..........
- From: John Francini <email@hidden>
- Date: Thu, 11 Jan 2007 09:23:09 -0500
Title: Re : Access of a global variable to more than one
process
Let's see if I can make this more clear.
UNIX doesn't work like Windows. You can't just put global
variables into a shared library and expect that to work. The
overall process design works against you. Windows DLL
data-sharing is a hangover from the days when Windows machines were
single-user computers, and you could safely assume that different
programs using the same shared DLL belonged to the same user.
This is not the case in UNIX.
You have to use one of the two UNIX mechanisms for sharing
memory: a memory map through the mmap() call, or System V shared
memory.
Period.
End of discussion.
John Francini
At 19:46 +0530 1/11/07, Gaurav Kumar wrote:
Hi
all,
I want to
make a shared library which has a global variable.
This library
is linked to two processes.
One main()
function increments the global variable value other main() function
has to read the
incremented
value.
How can I do
this on gcc 4.0 , i-mac with OSX as 10.4.6. ?
When i make
a shared library or dynamic library the global variables are placed in
local block of library, not
In the
shared block of library.
Is their any
way of coding to place my global variable in shared block of library?
I have tried
int nGlobalVariable _attrribute__((common)) =
2;
But this
does not work. As every new executable has initial value, not the
value set by one of the process.
I do not want to use shared memory like shmget, mmap
or something. Actually I want implementation
of
#pragma data_seg("shared")
Int nGlobal = 5;
#pragma data_seg()
on MAC OSX. It works properly on vc if I place
the above code in DLL..Different copy of executable access the same
memory.
I can set and get nGlobal from different process.Same
implementation I want on MAC, is it possible?
Please help
on this.
Thanks and
Regards
Kumar Gaurav
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
>
This email sent to email@hidden
--
John Francini, email@hidden
"The journey
is more important than the destination-that's part of life. If you
only live for getting to the end, you're almost always
disappointed." -Donald
Knuth
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden