Shop OBEX P1 Docs P2 Docs Learn Events
Lockset sempahore assembly syntax — Parallax Forums

Lockset sempahore assembly syntax

TransistorToasterTransistorToaster Posts: 149
edited 2007-03-25 02:36 in Propeller 1
Hello,
Did anyone play with the LOCKSET in ASSEMBLY with success?
I have a producer consumer paradigm between two cogs with semaphore protection. One is in assembly, while the other is in spin and the code behaves as if the semaphores are not working properly.

On p 234 od the Propeller manual, the example of how to use lockset is:
repeat until not lockset(semId)
' do the work on the shared resource
lockclr(semId)



I did not find an example for the assembly version, so this is what i came up with
label  lockset lock_id
if_c jmp #label
' do the work on the shared resource
lockclr lock_id




I am pretty certain that I correctly pass from the spin code to the asm code when I do my cognew(@asmStart, @var). If I remove the lockclr in the ASM code, then the spin code never passes though the wait on the lockset. I did not test the other way around because I honeslty don't know if I have the proper assembly code.

If you deal with this problem, please give me your input.
Thanks,
F

Comments

  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-25 01:41
    BTW, I did use the locknew command in spin before working with lockset.
  • cgraceycgracey Posts: 14,133
    edited 2007-03-25 02:36
    You got it right, but you need to add a "wc" after the lockset instruction. Always remember that no flags are affected unless you say they are.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
Sign In or Register to comment.