Guardian Programmer's Guide

Table Of Contents
Coordinating Concurrent File Access
Guardian Programmer’s Guide 421922-014
3 - 10
Avoiding Single-Process Deadlocks
3 Coordinating Concurrent File Access
Avoiding Single-Process Deadlocks
A process can also cause itself to deadlock, as shown in Figure 3-4.
Here, process C has opened the same file twice, returning two file numbers. The
process acquires a lock using one of the file numbers, then tries to read the file using
the other file number. Process C waits forever for itself to unlock the file.
Correct use of SETMODE function 4 allows your program to avoid this kind of
deadlock. Figure 3-5 shows how.
Figure 3-4. Single-Process Deadlock
Note. This kind of deadlock does not occur if the file is protected by the NonStop Transaction
Manager/MP (TM/MP), because TM/MP organizes locks by transaction ID, not file number.
See the NonStop TM/MP Application Programmer’s Guide for details.
VST018.VSD