News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Newer ThreadPool API

Started by johnsa, February 17, 2011, 08:11:55 AM

Previous topic - Next topic

johnsa

Hey all,

I was wondering if anyone had already used the new(er) ThreadPool API for win32 from MASM?
It's not present by default in the includes, but I know most of the C++ apps that are going multi-core or customer task schedulers are using this API. To be honest though if you follow the design for a task-stealing scheduler, I'm not sure if this API would really offer any benefit, as the whole point is that you don't have to create threads but rather have a (n-1) additional task threads (IE: one per core) which are blocking on a semaphore until they're assigned a task.

dedndave

i think that's a .NET class - not an API   :P
haven't seen too much .NET stuff in here

johnsa

Umm.. no it's a replacement of the original thread pool api, the new one was introduce for Vista/Server2008 and up.

ms-help://ms.w7sdk.1033/MS.W7SDKCOM.1033/dllproc/base/thread_pool_api.htm

Link to the base page straight from Platform SDK.

dedndave

my bad
i haven't gotten to win7, yet
as always, i am behind - still trying to learn xp   :P

GregL

FWIW, an MSDN Magazine article about it.  I've never used them.

    Improve Scalability With New Thread Pool APIs

Astro

I read about it but not used it myself. It's interesting, but I can't see from the article how this helps prioritize one pool over another (in other words, one group of threads over an another as the article alludes is beneficial in some situations - just seems like additional overhead)?

It also seems to me that the optimum number of thread pools is at least (processor count / 2) if not less, otherwise if you have an equal number of pools to processors, the threads in each pool start to choke on processor availability?

johnsa

I eventually landed up not bothering with the new api's. From my tests the approach I landed up taking seems to be working the best.

That is to use the traditional thread functions and have a "mini scheduler".
I create a thread per core, the scheduler then resumes/suspends them and essentially assigns in function pointers.

It allows me to assign tasks/jobs liberally to specific cores without any thread overhead and works beautifully for fine-grained parallel algorithms.

Astro