Aucb.563 fa.editor-p utcsrgv!utzoo!decvax!ucbvax!C70:editor-people Mon Mar 1 15:04:20 1982 Concurrent access problem >From Goldberg@RUTGERS Mon Mar 1 11:44:26 1982 The solution I have used in the editors I have written works as follows: 1. Before allowing a user to edit the file with intent to change it (i.e. not read-only mode) the editor ensures that nobody else is doing the same and simultaneously locks the file. On TOPS20 and TOPS10, this operation can be performed by opening the file in READ and WRITE mode upon reading it in. Using this method, you also discover if the user has the priviledges to write out the edited copy to replace the original, which is also desirable. The operating system does not allow more than one process to open the file this way. By interrogating the error flags upon a failure, the editor program can tell if the opening failed due to simultaneous access or for other reasons. 2. If another user tries to edit the file with intent to change it, the editor discovers that another user is doing the same and lets the user edit in read-only mode, if desired. 3. When the original user stops editing the file in whatever manner, the file channel (JFN) that was opened at the beginning of the editing (in READ/WRITE mode, recall) is closed so that others may now edit the file. This method prevents two users from editing the same source and producing two separate modified versions. Furthermore, it prevents the problem before any wasted editing is done. However, the operating system under which the editor runs must provide a file opening mode in which the file is write-locked. I vaguely recall that TENEX differs from TOPS20 in NOT providing this mode; and of course, other operating systems fail to provide it as well. Bob ------- ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.