8 - 12 8 - 12
MELSEC-Q
8 MULTITASK PROCESSING
Deadlock example
BASIC
program (A)
ZRESERVE 1
BASIC
program (B)
Resource with
resource number 1
Resource with
resource number 2
Request
In use
ZRESERVE 2
ZRESERVE 2
ZRESERVE 1
Program A requested to use
the resource with resource
number 2, but is put into the
wait status because program
B is using it.
Program B requested to use
the resource with resource
number 1, but is put into the
wait status because program
A is using it.
Both programs
were put into the
wait status and
keep each other
from continuing.
This situation is
called the deadlock
status.
Request
Request
Request
In use
In this case, if the "timeout" parameter is specified by each ZRESERVE instruction, a
timeout error occurs after the specified period of time and the execution interrupted
status can be released.
However, it is not preferable to release the execution interrupted status by generating
an error; it is recommended to modify the program appropriately.
(5) Types of resources which are managed by the OS program of the
communication module
Resources that do not require mutual exclusive control are as follows.
(a) Resources managed by the OS of the communication module
• Channel numbers for data communication with external devices.
• File numbers specified for input/output interaction with files and
devices.
• Priorities that define the program's execution order.
High priority numbers may be used in mutual exclusion, however.
For example, if an emergency processing at an error occurrence needs to
be executed preceding other programs.
• Character strings assigned to function keys
(b) Resources managed by each program
• Variables and Arrays handled by the program.
Resources other than the ones listed above can be accessed by all
programs.
For example:
Text screen
Keyboard
Files and disks
Extension devices of the communication module
Event numbers
Resource numbers etc.