451061@UOTTAWA.BITNET (Valentin Pepelea) (07/24/89)
I have been playing around with signalSemaphores lately. I have not had any success FindSemaphore()ing after I have AddSemphore()d them. Incidentally, I also found a bug in AddSemaphore(): ;==================================================================== ; AddSemaphore(signalSemaphore)(A1) ;==================================================================== AddSemaphore: jsr InitSemaphore ; InitSemaphore(signalSemaphore)(A0) lea SemaphoreList(a6),a0 ; Point to the semaphore list bra ProtectedEnqueue The problem is obviously that InitSemaphore() requires its argument in A0, unlike AddSemaphore which gets it in A1. The correct code should be: AddSemaphore: move.l a1,a0 ; Transfer the semaphore pointer jsr InitSemaphore lea SemaphoreList(a6),a0 bra ProtectedEnqueue If you cannot wait for OS 1.4 to solve this bug, you may force your C compiler to generate acceptable code by forcing it to load the signalSemaphore pointer in both the A0 and A1 registers. Just simply type: main() { AddSemaphore(&signalSemaphore,&signalSemaphore); { That is right, typing twice the argument will load up both A0 & A1 registers. If you are using prototypes, remember to modify the AddSemaphore declaration. If you are using pragmas, remember to change the AddSemaphore entry to: AddSemaphore(signalSemaphore,signalSemaphore)(A0/A1) And for our friendly neighborhood CATS, many bytes and instruction cycles could be saved in the Exec code by replacing the jsr Permit rts instructions found in AllocAbs(), CloseDevice(), CloseLibrary(), FreeMem(), FindPort(), ObtainSemaphore(), OldOpenLibrary(), OpenResource(), ReleaseSemaphore(), RemLibrary(), SumLibrary(), TypeOfMem() and perhaps a few other routiines by a simple rts. Perhaps the source code looks something like CALLSYS Permit rts so then define a new macro called JUMPSYS, equivalent to jmp LVO\1(a6). Valentin _________________________________________________________________________ "An operating system without Name: Valentin Pepelea virtual memory is an operating Phonet: (613) 231-7476 (New!) system without virtue." Bitnet: 451061@Uottawa.bitnet Usenet: Use cunyvm.cuny.edu gate - Ancient Inca Proverb Planet: 451061@acadvm1.UOttawa.CA