HPlogo Interprocess Communication: Programmer's Guide: HP 3000 MPE/iX Computer Systems > Chapter 4 Special Cases of IPC

Preventing Deadlocks

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

If multiple writers access a message file that has a small file limit, this can cause a deadlock due to the way MPE/iX monitors the writers that open and close the message file. MPE/iX does this by adding some extra records that are normally inaccessible. To leave room for these records, MPE/iX increases the file limit by 2 when the file is first created. This leaves enough room for one open and one close record per file.

As writers open the file and begin writing, they each use one record for an "open" record and reserve another for their "close" record. One record is used and the space for another is reserved per writer.

If the file has a very small file limit, or there is a large number of writers, it is possible to create a state in which all the space in the file is reserved. Writers are not able to write, because the file "looks" full (no available space). Readers are not able to read, because the file "looks" empty (no real records to be read). A deadlock has occurred.

To prevent such a deadlock, make the file limit larger than the number of writers; there should be room for more records than there will be writers. (You can set the limit when the file is created with the :BUILD command or the HPFOPEN intrinsic.) Another way to detect a deadlock (that is, using timeouts) is discussed in a later section of this chapter.

Feedback to webmaster