LOCK program instruction LOCK program instruction Syntax LOCK priority Function Set the program reaction lock-out priority to the value given. Usage Considerations LOCK 0 is assumed whenever program execution is initiated and when a new execution cycle begins. Changing the priority may affect how reactions are processed. Before using this instruction, be sure you know what reactions are active (and their priorities). Parameter priority Real-valued expression with a value from 0 to 127, which becomes the new reaction lock-out priority. Details When a program is EXECUTEd, it is placed on the execution stack.
When the program's task becomes the highest priority task in a time slice, the program's priority is set to 0 and it begins execution. During actual execution, a program's task can be suspended at the end of a time slice, in which case the task waits until the next time it is the highest priority task in a time slice. The LOCK instruction does not affect the task priority value within a time slice: It only changes the program priority of an executing program. Program priority becomes important when a reaction routine (REACT, REACTE, REACTI) is invoked.
A program can defer execution of a REACT or REACTI routine by setting the temporary program priority to a value higher than the REACT or REACTI program priority. This is the function of a LOCK instruction. For example, if a LOCK instruction changes the temporary program priority to 20, any REACT or REACTI interrupts with lower priority values are deferred. (REACTE routines cannot be deferred by priority considerations.) Deferred reactions are not ignored. Every time a new LOCK instruction is processed, any deferred reaction programs are checked to see if their priority is high enough for them to execute.
As soon as the program priority is lowered, all pending reaction routines with a higher priority are run according to their relative priority. The PRIORITY real-valued function can be used to determine the program priority at any time. eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 332