473,398 Members | 2,125 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,398 software developers and data experts.

How to increse the speed of program using multithreading

151 100+
How can we speed up the program using multithreading in C++.

Manish
Sep 25 '08 #1
4 2024
Banfa
9,065 Expert Mod 8TB
No it is impossible, by definition multi-threading adds more work for the processor to do, it now has to control scheduling the different threads.

You use multi-threading to allow you to run 2 threads of execution that have little or nothing to do with each other asynchronously so that you can write the code of each thread without having to worry about what the other thread is doing. Not to speed up the program.


Hmmm, well actually I guess with modern multi-core processors you may be able to get a speed increase. However I have a feeling that by default Windows runs all the threads of a single process on the same processor. But that is a guess I am not sure and I have absolutely no idea what happens on Linux.
Sep 25 '08 #2
Man4ish
151 100+
No it is impossible, by definition multi-threading adds more work for the processor to do, it now has to control scheduling the different threads.

You use multi-threading to allow you to run 2 threads of execution that have little or nothing to do with each other asynchronously so that you can write the code of each thread without having to worry about what the other thread is doing. Not to speed up the program.


Hmmm, well actually I guess with modern multi-core processors you may be able to get a speed increase. However I have a feeling that by default Windows runs all the threads of a single process on the same processor. But that is a guess I am not sure and I have absolutely no idea what happens on Linux.
How can we do multi threading for running multiple tasks .

Manish Gupta
Sep 26 '08 #3
JosAH
11,448 Expert 8TB
How can we do multi threading for running multiple tasks .

Manish Gupta
Start a thread for each available task and run your threads.

kind regards,

Jos
Sep 26 '08 #4
donbock
2,426 Expert 2GB
How can we do multi threading for running multiple tasks .
Writing thread-safe code takes discipline. You need to decide which variables should be local to each thread and which should be shared in common by all the threads. Then you need to implement your code such that it correctly implements those variable scope decisions. You need to design strategies to protect all the common variables so that simultaneous access from multiple threads doesn't cause problems.
Sep 26 '08 #5

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

Similar topics

4
by: chiefprogramer | last post by:
How to build up a good frame for a mathematical system and it's ultra-high-speed? Althought In PHP 5 there is a new Object Model. But I think the new Object Model is still very slow >< Just...
2
by: Joseph Heled | last post by:
Hi, My python module is built using the recommended distutils.core, which uses the -pthread flag. To my amazement this slows down the (-O3) code by a factor of two (!2) My gcc documentation...
1
by: Benjamin Lefevre | last post by:
I am currently developping a web crawler, mainly crawling mobile page (wml, mobile xhtml) but not only (also html/xml/...), and I ask myself which speed I can reach. This crawler is developped in...
30
by: Mike Cox | last post by:
Hi. I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program...
7
by: YAZ | last post by:
Hello, I have a dll which do some number crunching. Performances (execution speed) are very important in my application. I use VC6 to compile the DLL. A friend of mine told me that in Visual...
11
by: Sezai YILMAZ | last post by:
Hello I need high throughput while inserting into PostgreSQL. Because of that I did some PostgreSQL insert performance tests. ------------------------------------------------------------ --...
10
by: Flavio | last post by:
Hi, I try to write here because maybe my problem is a common one. I have a rather complicated multithreaded program, which uses the POSIX pthread standard. A master routine calls a series of...
1
by: anuragshrivastava64 | last post by:
Can the max limit of crosstab quer be increse from 255
1
by: madankarmukta | last post by:
HI, I created the process which is hook to launch just before the Desktop appears and after the login credentials are entered by the machine owner.In Xp it is giving the expected result i.e. my...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
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
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...
0
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...
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...
0
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...

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.