[ECOS] Coarse Grained Locking in Fileio package
Jeffrey R. Szczepanski
jrs@inscitek.com
Tue Sep 20 00:42:00 GMT 2005
I have noticed a "problem" in the eCos fileio package (packages/io/fileio)
relative to what amounts to rather "coarse grained" mutex protection during
a file close() operation.
Background: When the last open'ed file descriptor on a particular file
object is closed via close() implementation in the file
io/fileio/src/io.cxx, a call to cyg_fd_free() is required to deallocate the
file descriptor and the file object. Since in this case, this is the last
reference to the file object, the file system's fo_close() method is also
called. This entire operation here is undertaken in the context of holding
the system wide file descriptor lock named "fdlock". See
io/fileio/src/fd.cxx implementation of cyg_fd_free().
The side of effect of this is while any file system's fo_close() operation
is taking place ANY file descriptor operations (system wide) will be blocked
waiting for the pending close to complete....no matter what device or
filesystem the I/O is associated with. Since I/O device interactions are
likely required during say a disk based file operation, it is possibly
and/or likely that all I/O operations in the entire system that work through
file descriptors will blocked during this time period.
I think this operation needs a much more finer grained mutex locking
strategy.
My initial thought is that file object's reference count (f_ucount), in
principle, should be protected by the file object's own mutex, not by the
system wide "fdlock" mutex. This will allow the file-system's fo_close()
method to be invoked w/o still needing to hold the fdlock mutex, thereby
allowing all other file descriptors to operate concurrently with the close
operation.
I believe the set of changes needed would be isolated to the
io/fileio/src/fd.cxx module.
Thoughts/comments before I make an attempt to make the necessary changes to
the file!?
Thanks in advance,
Jeff
jrs at inscitek dot com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list