8 - 9 8 - 9
MELSEC-Q
8 MULTITASK PROCESSING
(1) To limit the access to the resource
In order to limit the access to resources, the following should first be understood:
(a) Mutual exclusive control of the resource is performed strictly under the
agreement between the programmers. The mutual exclusive control of the
resource is meaningless if such agreement is not followed.
1
1
Programmer A
Programmer B
The resource with a given resource number
(e.g., the text screen) must be referenced
using the same number by all programs.
1
5
Programmer A
Programmer B
If the resource number of a resource
(e.g., the text screen) is different
between programs, the mutual exclusive
control cannot be achieved.
(b) A program that uses a resource (see (2)) with an assigned resource number
must always execute the ZRESERVE instruction before it uses the
resource. After finishing using the resource, it must execute the ZRELEASE
instruction immediately so that another program can use the resource.
If the resource with the assigned resource number is already being used by
another program when the ZRESERVE instruction is executed, the
execution is halted until that program finishes using the resource and
executes the ZRELEASE instruction.
In order to prevent the execution of a program from being stopped for a
long period of time, specify a "timeout" when executing the ZRESERVE
instruction.
An error occurs if the resource is not available within the specified period of
time, which makes it possible to perform another processing by the error
handling.
(c) Try to limit the access to one resource at a time if possible when using
resources to which resource numbers are assigned.
(d) When using multiple resources with assigned resource numbers
simultaneously, decide the order of the specified resource numbers in each
ZRESERVE instruction. (To prevent deadlock of the program.)
For example, use the resources in sequence from the smaller or largest
resource number. (See (3).)