122-32000 Parallax Inc, 122-32000 Datasheet - Page 231

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-32000

Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Using
A user-defined, mutually-exclusive resource should be initially set up by a cog, then that
same cog should use
and pass the ID of that lock to any other cogs that require it. For example:
VAR
PUB SetupSharedResource
The example above calls
occurs. If the
shared with other cogs along with the address of the resource that
method used to communicate the
typically they are both passed as parameters to the Spin method that is launched into a cog, or
as the
Suggested Rules for Locks
The following are the suggested rules for using locks.
byte SemID
<code to set up user-defined, shared resource here>
if (SemID := locknew) == -1
else
<error, no locks available>
<share SemID's value with other cogs>
PAR
LOCKNEW
Objects needing a lock to manage a user-defined, mutually-exclusive resource should
check out a lock using
Only one cog should check out this lock. The cog that checked out the lock must
communicate
Any cog that needs to access the resource must first successfully set the lock
A successful “set” is when
set. If
must wait and try again later to get a successful “set”.
The cog that has achieved a successful “set” can manipulate the resource as
necessary. When done, it must clear the lock via
have access to the resource. In a well-behaved system, the result of
ignored here since this cog is the only one with the logical right to clear it.
parameter when launching an assembly routine into a cog. See
SemID
LOCKSET
is not -1, then a valid lock was checked out and that
LOCKNEW
SemID
returned
LOCKNEW
to all other cogs that will use the resource.
to check out a unique lock in which to manage that resource
LOCKNEW
TRUE
SemID
and stores the result in
LOCKSET(SemID)
, then another cog must be accessing the resource; you
4: Spin Language Reference –
and resource address depends on the application, but
and save the ID returned, we’ll call it
returns
LOCKCLR(SemID)
SemID
FALSE
Propeller Manual v1.0 · Page 231
. If that result is -1, an error
; ie: the lock was not already
SemID
COGNEW
so another cog can
SemID
is used for. The
LOCKCLR
, page 189.
needs to be
SemID
can be
SemID
here.
.

Related parts for 122-32000