comp.lang.ada
 help / color / mirror / Atom feed
* Direct_Io for Filesystem question
@ 2008-10-23 19:52 mhamel_98
  2008-10-23 21:54 ` Jeffrey R. Carter
  2008-10-23 22:13 ` anon
  0 siblings, 2 replies; 5+ messages in thread
From: mhamel_98 @ 2008-10-23 19:52 UTC (permalink / raw)


Hello all,

I have a "filesystem" that I've been using for some time now and with
some free time on my hand I thought I would play around with
concurrency.  I use the term filesystem very loosely, its simply an
instantiation of Direct_Io with a variant record, the first record in
a file is a header and the rest is data and it has worked well
enough.

My approach to concurrency was instead of giving the
direct_io.file_type to a requesting process, I would create my own
file_type which really only contains a token and location value.  The
token would direct the filesystem package to the actual file and the
location value which record to read/write.  When an 'open' is called,
it checks to see if the file is already open and if so returns an
existing token, and if not, opens it and creates a token to perhaps be
shared with others later.  All reads and writes are done using the
Direct_Io calls requiring a record index.  What the internal index of
the file_type is I don't care (maybe I should?)  This also works well
in a single user case.

In the case of two readers, the second reader reads a little bit then
tosses an  End_Error exception, the first reader completes normally.
Again, I'm wondering if the internal index value is relevant.  I would
have thought that explicitly telling direct_io which record to read it
would not care where it last read.

In the case of simultaneous reading and writing (only one writer
allowed), I designed the code so that when a reader opens the file, it
is told that the end of the file is where the writer is currently
located, so the reader will stop before overruning the writing
process' location, and this implementation is fine, no real time
requirements (that might be a neat addition later).  When I run a test
of one reader and one writer, on the surface everything seems ok, no
errors thrown.  When I go over the data later I get "discriminant
check failed" for a few records. Its as if the few moments a reader is
active, the writer tosses in garbage for the records written during
that time span.

I guess the big question is, am I ok to use Direct_Io for this sort of
operation?  It seems to me that the case of multiple readers is really
not much more than one reader doing very random reads?  If anyone has
specific information on the symptoms I'm seeing, I'd really appreciate
it!

Thanks for any advice or opinions!



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-10-24  0:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-23 19:52 Direct_Io for Filesystem question mhamel_98
2008-10-23 21:54 ` Jeffrey R. Carter
2008-10-23 23:14   ` mhamel_98
2008-10-24  0:14     ` Jeffrey R. Carter
2008-10-23 22:13 ` anon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox