468,513 Members | 962 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

open/fopen read/fread in multithreaded environment.

even thred is not part of C-std, i feel its most relavant to
comp.lang.c
hope it will not off-topic

-------
I am having data/or Text 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 results Nightmare ...!"
Nov 23 '07 #1
1 5414
Sheth Raxit said:
even thred is not part of C-std, i feel its most relavant to
comp.lang.c
comp.unix.programmer would be more relevant than comp.lang.c - and
comp.programming.threads is another possibility, according to my news
server.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Cam | last post: by
6 posts views Thread by DigitalDragon | last post: by
1 post views Thread by Michael Ferrier | last post: by
11 posts views Thread by typingcat | last post: by
6 posts views Thread by Rolf Schroedter | last post: by
8 posts views Thread by Asma | last post: by
13 posts views Thread by Blue | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.