open/fopen read/fread in multithreaded environment.



I am having data file, which is only used for reading by
multiplethreads in same process.

Reading may be done by in following possible way.
1.each Thread fopen,fread,fclose <fread may be called in loop>
2.each Thread open, read,close <fread may be called in loop>
3.Main Thread will fopen, childthread will fread in loop , mainthread
will fclose at end.
4.Main Thread will open, childthread will read in loop , mainthread
will close at end.

<in 3 and 4 above return value of open/fopen will be global value <or
may be pass to function but i think it is shared between multiple
thread.>

Assuming there will be a main thread and 60 other thread, Assuming no
thread is writing to file do i need to have any of above code having
pthread_mutex_lock/unlock ?

i.e. i want to know any code is critical section ? assuming the
variable in which they are reading are all function's local
variable,<dynamic memory are referred by differnt pointer of each
thread so no worry>


Thanks,
Raxit
"Thread, Mutex, Buggy Code, Deadline result Nightmare ...!" <writing
at 11:15 pm from office> :)
.



Relevant Pages

  • open/fopen read/fread in multithreaded environment.
    ... multiplethreads in same process. ... Reading may be done by in following possible way. ... 1.each Thread fopen,fread,fclose <fread may be called in loop> ...
    (comp.programming.threads)
  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)
  • Re: Problem with a script
    ... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in a loop. ... You still have them as uniquely named array indexes... ... I believe that for the new guy this code would be readable, and identifying problems should really not be any more difficult with this, plus I think that it actually might save some time to write the actual code from the beginnig, even though it's not at it's final stage, instead of first writing everything spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend an hour reading your entire code and parsing it in their head, you wont get any help and have to solve the problem by yourself. ...
    (comp.lang.php)
  • Re: advice and/or help on glReadPixels
    ... I could not see any "BRGA" in the documentation. ... Is it possible that some cards are not ... >>> a) Try reading the entire RGB instead of just the red. ... a quick integer loop with a mask & shift is ...
    (comp.graphics.api.opengl)
  • Re: Program compiled on intel acting weired
    ... The data file is open for read but then it gets overwritten by what ... Reading from the standard ... > has special syntax to achieve things like that, ... Wanting to process the output with some other program. ...
    (comp.lang.fortran)