LOCKSET and friends - am I missing something?
Bill Henning
Posts: 6,445
I needed some locks, so I read up on LOCKNEW, LOCKSET, LOCKCLEAR and LOCKRET.
Unless I am missing something, they are no more efficient than agreeing on a hub memory location, and using something like:
If so, the only advantage to using locks is to save a couple of registers. It would be nicer if lockset would wait until it the lock was clear.
Am I missing something?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
my 6.250MHz custom Crystals now available - run your Propeller at 100MHz!
Las - Large model assembler for the Propeller (alpha version released)
Largos - a feature full nano operating system for the Propeller
www.mikronauts.com - a new blog about microcontrollers
Unless I am missing something, they are no more efficient than agreeing on a hub memory location, and using something like:
waitlock rdbyte reg,lockptr wc
if_nc jmp #waitlock
wrbyte one,lockptr
vs.
waitlock lockset 1 wc
if_nc jmp #waitlock
If so, the only advantage to using locks is to save a couple of registers. It would be nicer if lockset would wait until it the lock was clear.
Am I missing something?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
my 6.250MHz custom Crystals now available - run your Propeller at 100MHz!
Las - Large model assembler for the Propeller (alpha version released)
Largos - a feature full nano operating system for the Propeller
www.mikronauts.com - a new blog about microcontrollers

Comments
They are useful in some situations...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
If you translate the lock functionality to your code, the lock-instruction is doing the read and write in one cycle which makes sure that no other COG can get the lock at the same time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
my 6.250MHz custom Crystals now available - run your Propeller at 100MHz!
Las - Large model assembler for the Propeller (alpha version released)
Largos - a feature full nano operating system for the Propeller
www.mikronauts.com - a new blog about microcontrollers