473,698 Members | 2,554 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 8156
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
1786
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
5130
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
2015
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
1994
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
12256
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
3625
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
3611
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
3801
by: subaganesan | last post by:
hello i am in need to upload multiple files. help me.......
4
17434
by: abdunnabisk | last post by:
How to upload multiple files at a time using HttpWebRequest in c#? thanks Abdun Nabi Sk
3
2883
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
8685
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
8612
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
9171
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...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
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
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2008
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.