Article View: comp.sys.amiga.tech
Article #5421Re: Amiga semaphores (HELP!)
From: Valentin Pepelea
Date: Mon, 24 Sep 1990 20:02
Date: Mon, 24 Sep 1990 20:02
28 lines
1832 bytes
1832 bytes
In article <2290006@hp-ptp.HP.COM> jimg@hp-ptp.HP.COM (Jim_Garrison) writes:
>
> I tried adding the LocalAddSemaphores() which John Suchs suggested to my
> program. It still doesn't work! Please note that I am using NAMED semaphores
> here, maybe that's what's causing my problems. Even after I have run this
> program once (or more) FindSemaphore(name) still returns NULL. Do named
> semaphores work?
> ...
> Sample program follows:
> ...
> LocalAddSemaphore(sem, "test1");
All right, here's what's happening. While you are allocating the semaphore
structure dynamically, the string "test1" is part of the program's global
variables. When the program exits, all variables disappear. Therefore when
you first run the program, the semaphore is indeed added properly to the
system.
But as soon as the program exits, the "test1" string is freed, and the memory
in which it resided is likely to be soon overwritten. Do an AllocMem() for the
name field of the semaphore, then copy the string in there. That will do it.
Valentin
--
The Goddess of democracy? "The tyrants Name: Valentin Pepelea
may distroy a statue, but they cannot Phone: (215) 431-9327
kill a god." UseNet: cbmvax!valentin@uunet.uu.net
- Ancient Chinese Proverb Claimer: I not Commodore spokesman be
Technical Details
Message-ID:
<14625@cbmvax.commodore.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!rutgers!cbmvax!valentinReferences:
<2290004@hp-ptp.HP.COM> <2290006@hp-ptp.HP.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!rutgers!cbmvax!valentin From: valentin@cbmvax.commodore.com (Valentin Pepelea) Newsgroups: comp.sys.amiga.tech Subject: Re: Amiga semaphores (HELP!) Message-ID: <14625@cbmvax.commodore.com> Date: 24 Sep 90 20:02:42 GMT References: <2290004@hp-ptp.HP.COM> <2290006@hp-ptp.HP.COM> Reply-To: valentin@cbmvax.commodore.com (Valentin Pepelea) Organization: Commodore, West Chester, PA Lines: 28