Manual

Neuron C Reference Guide 201
Symbol Description
_NCC5 Defined for version 5 of the Neuron C compiler. This
version corresponds to Version 2.2 of the Neuron C
language.
_NEURONC Defined for all versions of the Neuron C compiler.
_NODEBUILDER Defined for the Neuron C compiler that is included with
the NodeBuilder FX Development Tool, and later versions.
_SHORTSTACK Defined for the Neuron C compiler that is included with
the ShortStack LonTalk Interface Developer utility for
model files.
Built-In Semaphore
For Series 5000 chips, you use the Neuron C __lock { } keyword, followed by a
code block, within the application or the interrupt service routine (the interrupt
task) to acquire the built-in binary semaphore and synchronize access to shared
resources. The __lock keyword precedes a block of code (within a pair of curly
braces) that is controlled by the semaphor.
The semaphore is not supported for the lowest system clock rates (5 MHz and 10
MHz).
You can use the __lock keyword within either Neuron C code or pure C code (for
example, within a library).
Example:
interrupt (IO_0) {
... // do something not guarded by the semaphore
__lock { // acquire semaphore
... // do something guarded by the semaphore
} // release semaphore
... // more unguarded code
}
Because there is only one semaphore, you cannot nest locks. Nested locks yield a
compiler error, NCC#585. While the compiler detects and prevents direct nesting
of __lock{ } constructs within the same function, when task, or interrupt task, the
compiler does not detect runtime nesting.
Example: The following example illustrates nesting of locks at runtime.
void f() {
__lock {
... // do something
}
}
interrupt (IO_0) {