473,748 Members | 4,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write output on multiple files using multithreading?

151 New Member
Hi,

I am newbie to multi-threading. I am working on one pblm where i need to process 24 files (each size = 3 GB) and write the output onto multiple files(24). Each file takes around 1 hour to process. Is it possible to write data onto multiple files concurrently using multi-threading?
Thanks in advance.
Jan 21 '11 #1
9 8162
horace1
1,510 Recognized Expert Top Contributor
you can process multiple files in a single threaded program so should be no problem in a multithreaded program. You may have limitations on the number of concurrently open files though; this depends on operating system, compiler, configuration at link time, etc.
Make sure when you attempt to open the files that you check they open OK and if not display an error message indicating the problem.
Jan 21 '11 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Won't this make it slower? The hard drive is going to be a bottleneck. It's going to be jumping around like crazy trying to write a bunch of files at the same time instead of writing contiguous blocks.
Jan 21 '11 #3
horace1
1,510 Recognized Expert Top Contributor
I would assume we are talking about a complex data processing task. I have done similar things with Gbytes of satelite data (not 24 concurent files though) and leave it processing for days.
Jan 21 '11 #4
donbock
2,426 Recognized Expert Top Contributor
The C Standard does not require the stdio file access functions to be thread safe. I would not count on being able to access the same file simultaneously from different threads (I would not even have the same file open in different threads at the same time). You could get around this by having multiple processing threads that each enqueue I/O transactions to a single file-access thread; or by using semaphores to make all file access single-threaded.
Jan 22 '11 #5
Man4ish
151 New Member
Thank you very much for your quick response. I can write to multiple files simultaneously but speed is (processing time for one file)*24 times. There is not much speed improvement. Is there any way to speed up the process?
Jan 23 '11 #6
Rabbit
12,516 Recognized Expert Moderator MVP
I thought that would happen. Actually, I'm surprised it wasn't slower than sequential writing. It's a limitation of hardware, not software. I don't see a way around it unless you upgrade your hardware. Faster RPM drives coupled with a raid array.
Jan 23 '11 #7
Man4ish
151 New Member
Hi,

I just noticed, it is slower than sequential writing. My hardware configuration is good (24 core).Why it is slower than sequential writing?

Thanks
Jan 23 '11 #8
Rabbit
12,516 Recognized Expert Moderator MVP
It doesn't matter how fast your processor is. The choke point is the hard disk. You need multiple hard disks in a raid array.
Jan 23 '11 #9
horace1
1,510 Recognized Expert Top Contributor
if sequenctial writting gives the expected results why not use it? Is run time critial, cannot you leave it overnight? It can be very difficult to speed up a complex data processing task. Some ideas
1. look at the algorithm you are using - can you make it more efficent ?
2. check the compilers optimisation level
3. use faster disks (see previous contributions)

what about using a computing cluster such as Beowulf
http://www.linux.org/docs/ldp/howto/...x/systems.html

have a look at
http://www.linux.org/docs/ldp/howto/...g-HOWTO-1.html

however, the hardware/software combination depends upon what you are doing and we don't have sufficent details to give explicity advice.
Jan 23 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1787
by: Will | last post by:
I know I am searching using the wrong words because I can't seem to find a simple answer on this. Here's what I want to do. helper.inc <!php var $fileName2; class helper { function funcOne($fileName) {
1
5134
by: Susan | last post by:
Is it possible to use PHP with VBScript or JavaScript to upload multiple files. I'd like to automate the upload of a complete directory (not using FTP). I don't need a common form with several upload boxes. Thanks in advance, Susan
0
2020
by: Web learner | last post by:
Individual file download works fine. But when I try to download multiple files, for example using wildcards in the following code, I get error. How to solve it? System.Net.WebClient Client = new System.Net.WebClient(); Client.DownloadFile("ftp://123.123.456.0/*.RPT", @"C:\downloadedFiles\*.RPT"); Are there other possibilities??
2
1996
by: | last post by:
Hi, I have an idea that I want to write to many (qty unknown untill run time but in the order of 5) text files as my application runs. They're log files dealing with different aspects of the application and will ultimately be sent to different users, hence why they have to be different files. I know that I want to be using the File System Object to manage files, but I don't know how to open many files, keep them open and write to them...
7
12264
by: Pete | last post by:
I need to import multiple tab delimited files for which I do not have the formats. All files have column headers in the the line. The files must be dynamic. The only common value is that the files are text and use tabs to delimit the column data. I can not use the File/Import as people using the program do not have the necessary experience to perform this function. Therefore, I need to programtically create unique tables for each...
2
3634
by: =?iso-8859-1?b?cultaQ==?= | last post by:
Hi, I would like to rename files (jpg's ones) using a text file containing the new names... Below is the code that doesn't work : ***** #!/usr/bin/python #-*- coding: utf-8 -*- from os import listdir, getcwd, rename import re
4
3615
by: maria | last post by:
I only use C++ with Visual Studio 6.0 for string manipulations in thousands of HTML pages on my website. Many times, the output files of many of my C++ programs contain a spanish question mark (¿) as their first character. What creates it? How do we avoid it? Thanks! maria
2
3805
by: subaganesan | last post by:
hello i am in need to upload multiple files. help me.......
4
17441
by: abdunnabisk | last post by:
How to upload multiple files at a time using HttpWebRequest in c#? thanks Abdun Nabi Sk
3
2886
by: Davo1977 | last post by:
Does anyone know a regular expression that will rename multiple files that have different extensions to have the same extension. For example, you could use this code when several text files exist in a directory but have slightly different extensions such as .txt,. TXT, or text. This expression should show how to rename them to all have .txt extensions. I understand i will nedd the character class so it contains a hypen, dot, slash and w+...
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.