K
klem s
1)
* I know almost nothing about how OS operates, but I read that file
system on Windows OS is thread safe. Does that mean that while thread
is reading from a particular file, OS won’t allow any other threads
to write to that file until the first thread is finished reading from
it?
* If so, wouldn’t that imply that we should put lock around code
accessing a file only when it is imperative that particular thread
should process that file before some other thread? Thus, lock on code
accessing a file should only be used when the order in which threads
access the file is important?
* But if we don’t care in what order threads access that file, but
instead our only concern is that whichever thread is first to access
the file won’t get interrupted in the middle of processing the file by
some other thread ( which would then proceed to read/write to that
file before the first one is finished ), then we don’t have to put
locks around that code, since OS takes care of synchronization?!
2)
a) I assume FileStream instances are not thread safe?
b) This question probably won’t make much sense, but anyways …I know
that’s not the case, but would Net having some kind of monitoring
system, which would make FileStream instances accessing the same file
thread safe with respect to each other ( thus if thread 1 was
accessing file via Filestream_1.Write, then if thread 2 would try to
access same file via FileStream_2.Write, Net would put
FileStream_2.Write “on hold” until FileStream_1.Write was finished ),
be a bad idea?
In other words, how would this limit the functionality of FileStream
instances compared to functionality they have now?
Thank you
* I know almost nothing about how OS operates, but I read that file
system on Windows OS is thread safe. Does that mean that while thread
is reading from a particular file, OS won’t allow any other threads
to write to that file until the first thread is finished reading from
it?
* If so, wouldn’t that imply that we should put lock around code
accessing a file only when it is imperative that particular thread
should process that file before some other thread? Thus, lock on code
accessing a file should only be used when the order in which threads
access the file is important?
* But if we don’t care in what order threads access that file, but
instead our only concern is that whichever thread is first to access
the file won’t get interrupted in the middle of processing the file by
some other thread ( which would then proceed to read/write to that
file before the first one is finished ), then we don’t have to put
locks around that code, since OS takes care of synchronization?!
2)
a) I assume FileStream instances are not thread safe?
b) This question probably won’t make much sense, but anyways …I know
that’s not the case, but would Net having some kind of monitoring
system, which would make FileStream instances accessing the same file
thread safe with respect to each other ( thus if thread 1 was
accessing file via Filestream_1.Write, then if thread 2 would try to
access same file via FileStream_2.Write, Net would put
FileStream_2.Write “on hold” until FileStream_1.Write was finished ),
be a bad idea?
In other words, how would this limit the functionality of FileStream
instances compared to functionality they have now?
Thank you