943,154 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 359
  • C++ RSS
Jan 31st, 2010
0

Multithreading slower?

Expand Post »
So I've got this program I made, and I wanted to speed it up, using multithreading, to make use of my quad core. The program itself fully supports multithreading. The problem is, that when I'm running the program, using just one; CreateThread() it finishes in 6seconds, if I run 2 it finishes in about 12, and with the same result, why would single threading be faster? - The timer is started after the thread creation, so it isn't the extra overhead!

Please help me out, my brain is hurting >.<

Could it be the Windows API threads?
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Skeen is offline Offline
77 posts
since Nov 2009
Jan 31st, 2010
0
Re: Multithreading slower?
Thread management takes cpu cycles...
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jan 31st, 2010
0
Re: Multithreading slower?
Click to Expand / Collapse  Quote originally posted by jwenting ...
Thread management takes cpu cycles...
True, but equal to 3CPU cores out of 4?
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Skeen is offline Offline
77 posts
since Nov 2009
Jan 31st, 2010
0
Re: Multithreading slower?
Multi-threading really works only if your process is going to be waiting on certain conditions. If your process locks up the CPU for 5 minutes, then running 2 processes will lock it up for 10 minutes. But if your process has some idle time somewhere, then you could get a gain.

Multi-threading is really used to support simultaneous processes, such as a web server etc and not really to speed up a process -at least on a single computer. If you want to use 2 computers with two seperate chips and buses, then that's a different story.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ireshagun is offline Offline
3 posts
since Jan 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Passing a 2d array created using vector to a function
Next Thread in C++ Forum Timeline: Problem with file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC