Unix Programming - open/fopen read/fread in multithreaded environment.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2007 > open/fopen read/fread in multithreaded environment.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author open/fopen read/fread in multithreaded environment.
Sheth Raxit

2007-11-22, 1:23 pm

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>
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com