Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » MT & File Access
MT & File Access [message #8369] Tue, 06 March 2007 01:23 Go to next message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
My application is a kind of viewer from files downloaded from the Web.

The GUI thread is the viewer.

There is also an updater thread that check for updates.

Im my current implementation, the GUI thread read local files written by the updater thread. Reads (GUI) and Writes (updater) are serialized.

I am not sure if this approach is OK:
- the GUI could be writting while the updater is also writting (i.e. Debug log),
- the GUI might be using FindFile while the updater is writting some files.

Is my implmentation right or should I gather all file acceses in a single thread ?

Any help is welcome (I'm new to MT),
Thanks,
Victor
Re: MT & File Access [message #8416 is a reply to message #8369] Thu, 08 March 2007 14:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
victorb wrote on Mon, 05 March 2007 19:23

My application is a kind of viewer from files downloaded from the Web.

The GUI thread is the viewer.

There is also an updater thread that check for updates.

Im my current implementation, the GUI thread read local files written by the updater thread. Reads (GUI) and Writes (updater) are serialized.

I am not sure if this approach is OK:
- the GUI could be writting while the updater is also writting (i.e. Debug log),
- the GUI might be using FindFile while the updater is writting some files.

Is my implmentation right or should I gather all file acceses in a single thread ?

Any help is welcome (I'm new to MT),
Thanks,
Victor


Well, generally, what you want to avoid is race condition, which almost always is caused when read(s) and write(s) to a single entity (file, variable) occurs at the same time.

In this case, situation is a little bit more complicated, as in fact written files are "external" entities; therefore you will most likely have to use some sort of file protection, similar to the one used to avoid simultaneous access from several processes.

Alternatively, you migh create some internal locking mechanism. I am afraid the topic and possible solutions are too widespread to give a better advice.

Well, maybe what you want to hear is: Yes, you can write one file on one thread and another file in another, that is not problem.

Mirek
Re: MT & File Access [message #8423 is a reply to message #8416] Thu, 08 March 2007 16:33 Go to previous message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
Quote:

Well, maybe what you want to hear is: Yes, you can write one file on one thread and another file in another, that is not problem.


Thanks, that's enough for me.

Victor

Previous Topic: Simulation in its own thread.
Next Topic: SlaveProcess and working directory
Goto Forum:
  


Current Time: Fri Apr 26 01:27:22 CEST 2024

Total time taken to generate the page: 4.93540 seconds