open/fopen read/fread in multithreaded environment.
- From: Sheth Raxit <raxitsheth2000@xxxxxxxxx>
- Date: Thu, 22 Nov 2007 09:41:57 -0800 (PST)
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> :)
.
- Prev by Date: Re: Detecting network file system
- Next by Date: Re: Best way to check when pty slave has closed?
- Previous by thread: Best way to check when pty slave has closed?
- Next by thread: which glibc my "self extractable"/ binary is using?
- Index(es):
Relevant Pages
|
|