473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 5671
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cam | last post by:
Hi I'm using this simple rss parser that i would like to have open in another window. But I'm very much a beginner in php scripting. Here is the script on the page <?php ...
6
by: DigitalDragon | last post by:
hi, i would like to use stream I/O functions to open a file from data that i have already stored in memory. eg. char some_text="Test"; int main()
1
by: Michael Ferrier | last post by:
Hi, I've used fopen() extensively to open web pages. I've found that there is a small minority of web pages that open fine in a browser, but are inaccessible using fopen(). Here are two such...
11
by: typingcat | last post by:
Is it possible to read another web page in PHP? If is ASP.NET, the code would be ------------ WebRequest req=WebRequest.Create("http://www.microsoft.com"); WebResponse res=req.GetResponse();...
5
by: JG | last post by:
Hi all, Does anyone know how the implementations on Linux and Windows handle synchronization between a read and write FD open to the same file. For example, if I have 2 FD open to file X.txt. ...
6
by: Rolf Schroedter | last post by:
(Sorry for cross-posting). I need to access large files > 2GByte (Linux, WinXP/NTFS) using the standard C-library calls. Till today I thought I know how to do it, namely for Win32: Use open(),...
8
by: Asma | last post by:
Dear Sir, I am trying to find a way to open a Word document using C language and read the text of word doc into a variable. (Turbo C on Dos 6.0). Can anyone please tell me which libraries in...
13
by: Blue | last post by:
Hi , Can any one please let me explain me the diffrences between "open"/ "fopen" or "read"/"fread" or "write/fwrite". I know that "open" /"read" / "write" are system calls and "fopen"...
9
by: ferbar | last post by:
Hi all, I'm trying to read from the txt file 'ip.packets.2.txt' using the read function. It seems everything ok, but I get a -1 when executing >>bytesr = read(fdo1, bufread, 2); The 'open'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.