11 - 462 11 - 462
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
If the specification of <timeout value> is omitted or "0:0:0:0" is specified in <timeout
value>, the program waits for an infinite time.
• It is possible to prohibit the use of multiple resources at any one time by specifying
multiple resource numbers in one program.
• When multiple programs use resources to which different resource numbers are
assigned, determine the order of the resource numbers specified in the ZRESERVE
instruction as follows in order to prevent programs from going into deadlock status (in
which case the execution cannot be made).
(The following shows a case where the resource numbers are specified from the
least order and the ZRESERVE instruction is executed.)
(Program-A-)
• •
ZRESERVE 0
ZRESERVE 1
ZRESERVE 2
ZRELEASE 2
• • • •
•
ZRELEASE 1
ZRELEASE 0
• •
•
• •
• •
• •
• • • •
•
(Program-B-)
ZRESERVE 1
ZRESERVE 2
ZRELEASE 2
ZRELEASE 1
• •
• • • •
•
• • • •
•
(Program-C-)
ZRESERVE 0
ZRESERVE 2
ZRELEASE 2
ZRELEASE 0
• •
•
• •
•
• •
•
• • • •
•
• • •
• • • •
•
• • •
•
• • • •
•
•
(Example of deadlock occurrence)
When programs -D- and -E- are being executed concurrently, if E executes line
number 150 before D executes line number 200, D stops executing at line number
200.
Then, if E tries to execute line number 220, the execution stops in line number 220
because D has already executed the ZRESERVE instruction and specified resource
number 0.
D waits for the execution of the ZRELEASE instruction for resource number 1 and E
waits for the ZRELEASE instruction for resource number 0, which means that the
two programs keep each other from being executed.
(Program-D-)
• •
150 ZRESERVE 0
200 ZRESERVE 1
250 ZRELEASE 1
260 ZRELEASE 0
• •
•
• •
• •
• •
(Program-E-)
150 ZRESERVE 1
220 ZRESERVE 0
260 ZRELEASE 0
270 ZRELEASE 1
• •
• •
• •
• •
• •
•
Deadlock status occurs.
1)
2)
3)
1)
2)
indicates the progress of the program execution time.
REMARK
• See Section 8.3 for the details about exclusive control of resources.
• See the ZRELEASE instruction.