Article View: comp.sys.amiga.tech
Article #2473Re: Semaphores
From: Michael Sinz - CATS
Date: Fri, 01 Dec 1989 23:54
Date: Fri, 01 Dec 1989 23:54
66 lines
2508 bytes
2508 bytes
In article <1716@mathrt0.math.chalmers.se> d5adria@dtek.chalmers.se (Martin Adrian) writes:
>I can't get the function AddSemaphore to work.
>
>My program looks like this:
>
>main()
>{
> struct SignalSemaphore ss;
>
> /* set name and pri */
>
> AddSemaphore(&ss);
Note that AddSemaphore is Broken in the 1.2/1.3 ROMs and you must use the
work-around published in AmigaMail and in the AutoDocs and in the
RKM: Includes & AutoDocs... (Blue cover...)
>
> ....
>
> RemSemaphore(&ss);
>}
>
>The guru will show up every time with different nubers.
>
>When i disassembled the exec function AddSemaphore it looked like this(Ks1.3):
>AddSemaphore: JSR _LVOInitSemaphore(A6)
> LEA SemaphoreList+LH_Head(A6),A0
> BRA xxxx ;do Enqueue
>
>When i looked up the functions in programmers guide i found that AddSemaphore
>wants the Semaphorepointer in A1 and InitSemaphore in A0.
>(The lattice proto/exec.h was wrong about this)
>
>InitSemaphore also destroys A0,A1,D0,D1.
>
>As far as i can see there is no way that this function can work.
>
> BTW this macro works fine.
>#define AddSemaphore(ss) InitSemaphore(ss),\
> Enqueue(ExecBase->SemaphoreList,&(ss)->ss_Link)
> ^
> the semaphore node
Note that you need to do the following:
InitSemaphore(ss);
Forbid();
Enqueue(ExecBase->SemaphoreList,ss);
Permit();
You MUST Forbid()/Permit()
>Is this a known bug in Exec ?
>
>Martin Adrian.
/----------------------------------------------------------------------\
| /// Michael Sinz -- CATS/Amiga Software Engineer |
| /// PHONE 215-431-9422 UUCP ( uunet | rutgers ) !cbmvax!mks |
| /// |
|\\\/// When people are free to do as they please, |
| \XX/ they usually imitate each other. |
\----------------------------------------------------------------------/
Technical Details
Message-ID:
<8792@cbmvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!cbmvax!mksReferences:
<1716@mathrt0.math.chalmers.se>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!cbmvax!mks From: mks@cbmvax.UUCP (Michael Sinz - CATS) Newsgroups: comp.sys.amiga.tech Subject: Re: Semaphores Message-ID: <8792@cbmvax.UUCP> Date: 1 Dec 89 23:54:48 GMT References: <1716@mathrt0.math.chalmers.se> Reply-To: mks@cbmvax.UUCP (Michael Sinz - CATS) Organization: Commodore Technology, West Chester, PA Lines: 66