Difference between revisions of "Multiplexed file access"

From BeebWiki
Jump to: navigation, search
m (Typo byte -> by)
 
m (1 revision)
 
(2 intermediate revisions by the same user not shown)
(No difference)

Latest revision as of 19:12, 8 March 2015

Non-multiplexed File Access

A file can be opened multiple times only according to the following rules:

  • a file can be opened multiple times for input as long as the file has not already been opened for output.
  • a file can be opened for output only as long as it has not already been opened for anything.

To see why, consider what would happen if this what not enforced.

If you could open a file multiple times to write to it then the written data would be inconsistent, increasingly so with the increased size of any buffering. If process A reads the first 16 bytes, and then process B writes byte 8, process A still has the old data. If process A then changes byte 9 and writes the first 16 bytes back, the byte 8 changed by process B is overwritten. There is no way to know what the correct data is.

Multiplexed File Access

Some systems allow file opening to be multiplexed so that multiple processes can read and write multiple times to and from the same file. The above rules are applied to portions of open files rather than the whole file. This can be useful for implementing database systems, and is usually implemented as a server process where the server can keep track of the multiple file access.

Consider a multiplexed file access system with a granularity of 1024 bytes. A process opens a file for update and sets its pointer to between 1024 and 2047. Any other process can also open the file, but cannot read or write to the area with pointer between 1024 and 2047.

The SJ MDFS allocated the 'M' access bit for this, but the functionality was never implemented.


Jgharston 20:41, 2 September 2007 (BST)