Page 2 of 2

Posted: Thu Nov 03, 2005 9:29 am
by blueznl
hmmm... does that mean datasection is always maintained in memory, or no, perhaps better put: does that mean that the address you pass from one program to another is valid and stays valid? i thought you couldn't rely on 'physical' adresses being the same to all programs... or is this ok these days on windows?

Posted: Thu Nov 03, 2005 10:33 am
by Dr. Dri
When you use adresses (for example a label) this adress refers to your process. So if it's the same program (what i know from the ExeFile) 2 identic adresses point to the same data.

I think this is "relative" adressing but i don't really know. :roll:
I don't know neither if you can get the physical adresses

Dri

Posted: Thu Nov 03, 2005 2:00 pm
by blueznl
now let's up the challenge: let's create two DIFFERENT programs that need to access the same data :-) preferably by allocating a piece of fixed memory?

i've been looking through the win32 api and i'm pretty sure there must be some way, but haven't found it yet...

Posted: Thu Nov 03, 2005 2:21 pm
by Dare2
That's a good challenge.

Would FileMapping (CreateFileMapping, OpenFileMapping) be a way to go?

Posted: Thu Nov 03, 2005 3:42 pm
by gnozal
There is already a userlib for this I think : GlobalSharedMemory (by Rings) http://pbosl.purearea.net/index.php?site=Libs . It uses file mapping IIRC.

Posted: Thu Nov 03, 2005 6:58 pm
by blueznl
ha solved it :-)

Posted: Thu Nov 03, 2005 7:01 pm
by blueznl
it's also another alternative to check what program came first, just see if you can open a filemapping, if not there's no instance running yet :-)

see here...

viewtopic.php?t=17542

Posted: Thu Nov 03, 2005 10:30 pm
by PB
I still don't know what's wrong with the single-line sempahore example, it
works just fine for me with Win 98se, ME, 2K and XP. (I couldn't make it
fail under Win98se as reported here, maybe the steps to make it do so
could be posted so I can see for myself?).

Posted: Fri Nov 04, 2005 10:13 am
by Dr. Dri
@PB
I said i tried semaphore, mutex and if the program crash, the semaphore or the mutex still exists and you can't launch the program again.
That's what happenned to me (win98 se)

Dri

Posted: Fri Nov 04, 2005 10:45 am
by PB
That's what I did too -- a sempahore under Win98se and I made the app
crash (by doing a GetClipboardText when the clipboard had >64K) and
I was still able to re-run it again, thus I believe the semphore died when
the app crashed. Anyway, that's my experience with it, and why I still
choose to use it to prevent multiple instances. <Shrugs>.

Posted: Fri Nov 04, 2005 12:56 pm
by blueznl
an laternative may be a named pipe, playing with that now