Date : Sat, 19 Jan 1985 01:31:17-MST
From : Ron Fowler <RFOWLER@SIMTEL20.ARPA>
Subject: Large number of simultaneously open files
Andy Klossner mentioned that you should take pains NOT to close a file open
only for read because
1) It's not necessary
2) Causes an unnecessary disk access
I must take exception to this; first, it's good programming practice to
close all open files, regardless of their read/write status. But more im-
portantly, multi-user operating systems (such as MP/M and TurboDOS) that allow
filesharing must keep a record in memory for each file; these systems release
this memory when a file is closed. Programs that open a large number of files
without closing them (CRCK.COM is a good example of this) tend to cause the
file lock space to be exhausted. This is an especially severe problem with
MP/M, where lock space is a fixed number of files (TurboDOS uses all avail-
able memory).
Closing a file open for read does NOT cause an unnecessary directory access
under CP/M 2.2; CP/M keeps a flag in the FCB that is set when a write oc-
curs (bit 7 of the S2 byte, for those who are interested ... 0=written); if
the file hasn't been written to, CP/M returns a successful close result,
but inhibits any disk update. --Ron Fowler