C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28691
Number of posts: 94711

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to read and write file faster? Posted by weixj2003ld on 17 Mar 2011 at 5:55 AM
how to read and write file on the disk faster?

Report
This post has been deleted. Posted by melanie14 on 21 Mar 2011 at 9:16 PM
This post has been deleted.
Report
Re: how to read and write file faster? Posted by weixj2003ld on 22 Mar 2011 at 5:15 PM
I want to use multi-thread,but I have some questions.
1. If read one large file(500G) with multi-thread,can it accelerate the speed?
2.If read many files and each thread read one,can it accelerate the speed?
3.If the multi-thread program would accelerate the speed,Must it run on multi-CPU? what about on multi-kernel?
Report
This post has been deleted. Posted by SundayForever on 22 Mar 2011 at 6:17 PM
This post has been deleted.
Report
Re: how to read and write file faster? Posted by nebgast on 24 Mar 2011 at 5:02 PM
: I want to use multi-thread,but I have some questions.
: 1. If read one large file(500G) with multi-thread,can it accelerate
: the speed?

Assuming that you are working with a multi-core CPU and lock the critical location of what is being read, but if you are reading one file in a concurrent manner are you really able to process the file? Unless the file is created to have X size bytes read concurrently and processed reading a single file on multiple threads might be pointless.

: 2.If read many files and each thread read one,can it accelerate the
: speed?

Yes, reading one file per thread could speed up the processing of the files. Given either a single-core or multi-core threading system.

: 3.If the multi-thread program would accelerate the speed,Must it run
: on multi-CPU? what about on multi-kernel?

Multi-threading on a single core uses the concept of time-slicing to fake multiple-threads, so it can potentially speed up the program depends on what's going on.

Multi-kernal - I don't know how to answer that question.
Report
Re: how to read and write file faster? Posted by AsmGuru62 on 26 Mar 2011 at 5:06 AM
When dealing with a single hard drive - multithreading may be slower. No matter how many CPU or cores you have - a single physical drive may cause excessive wear on the drive and slow processing.

Consider this: two threads read two files, separated physically by some amount of sectors. The hard drive heads must move to the 1st file and read the part of it, then next thread comes and heads move to 2nd file sectors, then process repeats - probably a lot of times - depends on a size of the part of the file being loaded. Since there is only one set of drive heads and it cannot be really shared at run-time (like CPU cores) - some thread always will wait until other thread is moving these heads.
Report
Re: how to read and write file faster? Posted by weixj2003ld on 29 Mar 2011 at 1:43 AM
thk u very much.
Report
This post has been deleted. Posted by alinora11 on 28 Mar 2011 at 12:20 PM
This post has been deleted.
Report
This post has been deleted. Posted by fuatgenc on 19 Apr 2011 at 6:25 AM
This post has been deleted.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.