🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Question about ReleaseSemaphore()

#2430
From: Doug Merritt
Date: Thu, 30 Nov 1989 17:17
41 lines
2568 bytes
In article <8763@cbmvax.UUCP> valentin@cbmvax.UUCP (Valentin Pepelea) writes:
>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?
>
>These comments are non Amiga specific; the principles of computer science
>simply don't allow you to release something you don't own.

The "principles of computer science" are not so inflexible; you're making
a thinly veiled "appeal to authority" -- a logical fallacy.

In point of fact, Panzer is simply trying to redefine "ownership", he is
*not* trying to redefine "semaphores". There is absolutely nothing wrong,
in theory, with wanting to set up two tasks as a single conceptual entity,
and have them share ownership of everything, including semaphores. Naturally
such shared semaphores could not then be used to synchronize those two
tasks, but in terms of his question, that's irrelevent.

After all, there's nothing in the definition of a semaphor that says that
ownership is based on tasks. They are frequently used for shared memory
parallel processor synchronization, for instance, and in that case the
ownership is based on which *cpu* grabbed it. Other non-Amiga-specific
examples are a single thread of control which has different sets of
subroutines using semaphores to mediate resource access. Or same thing
with coroutines.

So the question is simply "what defines the owner of a semaphore, and
can I muck around with it", and this *is* Amiga specific.

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

This sounds like pretty good advice, specific to the Amiga.
	Doug
-- 
Doug Merritt		{pyramid,apple}!xdos!doug
Member, Crusaders for a Better Tomorrow		Professional Wildeyed Visionary
Technical Details
Message-ID: <553@xdos.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!usc!apple!motcsd!xdos!doug
References: <3156@hub.UUCP> <8763@cbmvax.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!usc!apple!motcsd!xdos!doug
From: doug@xdos.UUCP (Doug Merritt)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Question about ReleaseSemaphore()
Keywords: ReleaseSemaphore
Message-ID: <553@xdos.UUCP>
Date: 30 Nov 89 17:17:21 GMT
References: <3156@hub.UUCP> <8763@cbmvax.UUCP>
Reply-To: doug@xdos.UUCP (Doug Merritt)
Organization: Hunter Systems, Mountain View CA (Silicon Valley)
Lines: 41