[M3devel] random-acces I/O
Dragiša Durić
dragisha at m3w.org
Sun Mar 2 17:06:07 CET 2008
On Sat, 2008-03-01 at 18:24 -0800, Mika Nystrom wrote:
> Yes, I am aware of that. My point was simply that if you want
> a reader and writer accessing the same data it's probably easiest
> to connect together the reader and writer directly, somehow, and write
> some sort of "watcher" that flushes modifications to disk "on the side"
> of the interaction between the reader and writer.
But not back to back, reader to writer, as in RdWrPipe.
> Btw, I do have some code that does this sort of thing (not entirely
> random access), and to run both on Unix and NT386GNU, yes, I do
> close the file every time I "turn it around" from reading to writing
> or vice versa.
I have database library doint exactly that, with (of course) OO,
transactions, multinode access and much more. Locking mechanisms are old
hat, there is lot of options. Skip buffers, even readers/writers, and
you don't have to close/reopen file. Point is, in Hendrik's case, he
must define usage patterns for both Modula-3 and non-Modula-3 code, and
follow them.
>
> Mika
>
>
> =?UTF-8?Q?Dragi=C5=A1a_Duri=C4=87?= writes:
> >rdwr is package by Blair MacIntyre and it's not related to anything
> >File.* except indirectly, ie if you make File Wr part of TeeWr.
> >
> >On Sat, 2008-03-01 at 14:49 -0800, Mika Nystrom wrote:
> >> Hi Hendrik,
> >>
> >> The answer is, "it depends." As a matter of fact this was my biggest
> >> area of trouble when porting a program from PM3 on Unix to
> >> PM3/Klagenfurt for NT386GNU. On NT386GNU, the default is for
> >> Modula-3 to avail itself of Windows's mandatory file locking, whereas
> >> POSIX has no such thing. This means that a Modula-3 program on
> >> NT386GNU can't even open a file for reading if you are "lessing"
> >> it for instance. I am sure it can be worked around, but I never
> >> bothered to figure out how, sorry (because the behavior I needed
> >> was in fact strict locking of this kind, which I had to go to special
> >> lengths to get on Unix!)
> >>
> >> On Unix, things are a bit more as you describe them, but not exactly.
> >> You can definitely have an Rd.T and a Wr.T on a single file, but I
> >> do not believe that the Rd.T and Wr.T will be aware of each other's
> >> existence (I could be wrong). However, there is a package called
> >> rdwr(?) that I think may have the sort of functionality you're
> >> looking for. Maybe.
> >>
> >> File locking is strictly an OS issue as far as I know and that is not
> >> something that Rd and Wr concern themselves with.
> >>
> >> If you need this kind of low-level access I have a feeling Rd and Wr
> >> are too high-level for you. I would suspect you want to build something
> > with rdwr (or some other means of getting an Rd out of a Wr or vice
> >> versa) and then extend it with routines for maintaining a faithful
> >> disk-based copy of what you want... using lower-level access methods.
> >>
> >> Oh yes Rd and Wr are documented in detail in chapter 6 of the Green Book.
> >>
> >> Mika
> >>
> >> hendrik at topoi.pooq.com writes:
> >> >I need to do direct-access I/O from a Modula 3 program with a file
> >> >format that is externally specified. It is necessary to both read and
> >> >write in random fashion during a run of the program, prefereably without
> >> >having to close or open the file each time.
> >> >
> >> >I expect the answers to the following questions are "Yes", but I'd
> >> >appreciate confirmation:
> >> >
> >> > ? If I have a File.T (obtained from FS.OpenFile) can I have both a
> >> > Rd.T and a Wr.T active on it simultaeously?
> >> >
> >> > ? Will things written using the Wr.T be immediately available
> >> > for reading with the Rd.T, with no buffereing problems?
> >> >
> >> > ? Are there methods for locking the file -- or portions of it --
> >> > against simutaneous access by other programs, including ones written
> >> > in other languages?
> >> >
> >> >-- hendrik
> >--
> >Dragiša Durić <dragisha at m3w.org>
--
Dragiša Durić <dragisha at m3w.org>
More information about the M3devel
mailing list