I expect this will be a hard question you don't have to reply today.
I'm creating a program that uses multiple threads to read from a file, manipulate the data, and put it into another file in the same
order in which it was read.
I'm not certain how to do this at all. You see one thread reading from the file would not be able to keep up with several threads (several i.e. an unspecifiable amount limited only to the number of CPUs/cores.)
Now, if I had my threads read from the file they would need to either:
1: Lock it.
2: Read and get the position in the file at the same time.
(by the way I am doing low level file descriptor reading and writing)
Now if I locked the file for reading I would also have to at the same time lock the file for writing at the same time which might not work.
Even if it did it would eventually degenerate into a "lock the files war." Like having a half duplex network running at over 2/3 load.
The second option therefore, seams better, but how do you tell the compiler to execute the tell/seek functions at the same time?
I've brainstromed as best as I am able but can't seem to figue out a good method of doing this.
I'm running GCC 4.7.x
Don't bother with cross platform stuff, I'm not, at least currently interested.
As always, thanks for your insight.