Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost::thread to keep all cores busy
From: Internet Retard (webretard_at_[hidden])
Date: 2010-07-26 10:37:39


> using multiple threads in your application it not assure you that both
> your cores will be used, most likely yes but not 100% sure, unless:
> 1) The threads do not interfere each other
> 2) You did a CPU affinity for each your thread.

Yes. The threads will not share data and will not interact in any way.

> what you can do is the following pattern:
>
> 1) Insert your jobs in a thread safe container (or do a wrapper around
> an std one).
> 2) Launch *all* your threads giving them a reference to the above
> container.

All at once? What if I have millions of tasks rather than a few? I want to be working on 2 tasks all the time. If my queue is not empty, then as a thread ends, it sees there are more tasks in the queue and gets one.

> 3) Then each thread have to do in the main loop (pseudo code here):
> Job* job = NULL;
> while( job = container.extract_job() ) {
> work on job;
                                               
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net