Guardian Procedure Calls Reference Manual

Considerations
File numbers
Within a process, the file numbers are unique. The lowest numeric file number is 0 and is
reserved for $RECEIVE. Remaining file numbers start at 1. The lowest available file number is
always assigned. Once a file is closed, its file number becomes available, and a subsequent
open can reuse that file number.
Maximum number of open files
The maximum number of files in the system that can be open at any given time depends on
the space available for control blocks; access control blocks (ACBs), file control blocks (FCBs),
and open control blocks (OCBs). The amount of space available for control blocks is limited
primarily by the physical memory size of the system. Each process can have up to one
megabyte of space for ACBs; the default is 128 kilobytes for ACBs.
Multiple openings by the same process
If a given file is opened more than once by the same process, a new ACB is created for each
open. This provides logically separate accesses to the same file because a unique file number
returns to the process for each open. Whenever you reference a file in a procedure, the file
number is supplied by you in the filenum parameter of the procedure.
Multiple opens on a given file can create a deadlock. This shows how a deadlock situation
occurs:
OPEN( MYFILE , filenuma ... );
! first open on file MYFILE.
.
.
OPEN( MYFILE , filenumb ... );
! second open on file MYFILE.
.
.
OPEN( MYFILE , filenumc ... );
! third open on file MYFILE.
.
----
d .
e LOCKFILE ( filenumb, ... ); ! the file is locked
a . ! using the file number
d . ! associated with the
l . ! second open.
o READUPDATE ( filenumc, ... ); ! update the file
c . ! associated with the
k . ! third open.
----
Locks are granted on an open file (that is, file number) basis. Therefore, if a process has
multiple opens of the same file, a lock of one file number excludes access to the file through
other file numbers. The process is suspended forever if the default locking mode is in effect.
You now have a deadlock. The file number referenced in the LOCKFILE call differs from the
file number in the READUPDATE call.
Limit number of times file can be open
There is a limit to the total number of times a given file can be open at one time. This
determination includes opens by all processes.
OPEN Procedure (Superseded by FILE_OPEN_ Procedure) 901