Propeller Manual

Table Of Contents
LOCKNEW – Spin Language Reference
Page 124 · Propeller Manual v1.1
If a resource is no longer needed, or becomes non-exclusive, the associated lock
should be returned to the lock pool via
LOCKRET(SemID). Usually this is done by the
same cog that checked out the lock originally.
Applications should be written such that locks are not accessed with
LOCKSET or LOCKCLR
unless they are currently checked out.
Note that user-defined resources are not actually locked by either the Hub or the checked-out
lock. The lock feature only provides a means for objects to cooperatively lock those
resources. It’s up to the objects themselves to decide on, and abide by, the rules of lock use
and what resource(s) will be governed by them. Additionally, the Hub does not directly
assign a lock to the cog that called
LOCKNEW, rather it simply marks it as being “checked out”
by a cog; any other cog can “return” locks to the pool of available locks. Also, any cog can
access any lock through the
LOCKCLR and LOCKSET commands even if those locks were never
checked out. Doing such things is generally not recommended because of the havoc it can
cause with other, well-behaved objects in the application.
See
LOCKRET, page ; LOCKCLRT 125 , page 120; and LOCKSET, page 126 for more information.