Omron NJ501-1500 Reference Manual page 925

Machine automation controller nj-series
Hide thumbs Also See for NJ501-1500:
Table of Contents

Advertisement

• If Lock instructions are used in more than one task, a deadlock may occur if they are positioned
poorly. A Task Execution Timeout Error will occur if there is a deadlock and a total stop is performed.
Execution priority
High
Task T1
Task T2
Low
The priority of T1 is higher than the priority of T2,
so T2 is interrupted and execution of T1 is started.
T1 executes a Lock instruction with an Index value
of 2. Therefore, execution of T1 is interrupted until
the Unlock instruction is executed in T2.
• An error occurs in the following case. The value of Out does not change.
• There are more than 16,777,215 lock region at the same time.
Sample Programming
Here, program P1 in task T1 and program P2 in task T2 both access the same global variable GTable1.
When the value of write request WriteReq changes to TRUE, P1 writes one record to record array
GTable1.Record[] and increments GTable1.Index. When read request ReadReq changes to TRUE, P2
decrements GTable1.Index and reads one record from GTable1.Record[].
The Lock instruction is used so that reading and writing do not occur at the same time.
Program P1
Record
written.
Task T1
Definition of Global Variable GTable
Data type
Variable
USERTABLE
Index
Record
Global Variables
Variable
GTable1
NJ-series Instructions Reference Manual (W502)
Lock(1)
Lock(2)
Lock(2)
T2 executes a Lock instruction with an Index value of 1.
Therefore, execution of T2 is interrupted until the
Unlock instruction is executed in T1.
GTabel1
Record
Record 0
read.
Record 1
:
Record n
Data type
STRUCT
INT
ARRAY[0..99] OF LREAL
Data type
Initial value
USERTABLE
(Index:=0,Record:=[100(0.0)])
2 Instruction Descriptions
Normal execution
Lock region
Execution interrupted.
Here, restarting the execution of
both of the tasks must wait until
the Unlock instruction is executed
in the other task, i.e., they are
deadlocked.
Lock(1)
Program P2
Task T2
Comment
Record storage structure
Index
Record array
Comment
Record storage structure
2
2-877

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Nj501-1300Nj501-1400

Table of Contents