🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #2407

Re: Question about ReleaseSemaphore()

#2407
From: Valentin Pepelea
Date: Wed, 29 Nov 1989 22:50
28 lines
1915 bytes
In article <3156@hub.UUCP> panzer@cornu.ucsb.edu (Panzer) writes:
>
>What happens if a task ReleaseSemaphore()'s a semaphore which another
>task had previously ObtainSemaphore()'d?  The semaphore structure
>has a field for the owner of the semaphore; would changing this field 
>prior to the release be necessary or desirable? 

These comments are non Amiga specific; the principles of computer science simply
don't allow you to release something you don't own. This is true for memory,
file handles, locks and certainly semaphores. Tranfer of ownership is tricky
and in some cases illegal.

What you seem to need is "private semaphores". These semaphores are basically
owned by one task which can modify the count, but other tasks can only read the
count.

You are better off implementing your mutual-exclusion/synchronising mechanism
using the Signal() and Wait() functions rather than changing the internal 
fields in the SignalSemaphore structure while it is being used. Needless to say,
if you hack the internal structure, your code will fail on future versions of
the operating system.

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: <8763@cbmvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!pyramid!cbmvax!valentin
References: <3156@hub.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!pyramid!cbmvax!valentin
From: valentin@cbmvax.UUCP (Valentin Pepelea)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Question about ReleaseSemaphore()
Keywords: ReleaseSemaphore
Message-ID: <8763@cbmvax.UUCP>
Date: 29 Nov 89 22:50:52 GMT
References: <3156@hub.UUCP>
Reply-To: valentin@cbmvax.UUCP (Valentin Pepelea)
Organization: Commodore Technology, West Chester, PA
Lines: 28