Re: [Algorithms] Multi-core efficiency item.
Brought to you by:
vexxed72
From: tbp <tb...@gm...> - 2006-07-30 02:30:58
|
On 7/30/06, Kelly Brock <kb....@sb...> wrote: > The intended usage is pretty simple. I need to process a bunch of > things which are not interdependent and use as many CPU's as possible. Each > thread uses a lockless accessor to the "things to execute" to retrieve what > it will execute and as such distributing the tasks is self balancing > (against the underlying OS thread scheduling, affinity masking 1:1 is only a > benefit depending on OS and usage intentions) up till the end where the > inverted semaphore comes into play. The inverted semaphore is used to allow > "one" of the threads to act as the final "clean up" thread for the tasks. > But it must be the "LAST" thread still executing on the tasks. Hence, > InvertedSemaphore in my current terminology. For a somehow similar problem, tile dispatching for a rtrt, i got decent results on win32 with a master/slave pattern: there's a master semaphore controling slave's scheduling - ReleaseSemaphore(masterphore, num_slaves) - and an array of per slave docking semaphores which the master sleeps on - WaitForMultipleObjects(num_slaves, dockphores, ...) - and slaves raise when they are done. It's not exactly what you've asked for (or pretty), but at least it limits trips to ring 0. Performance wise it doesn't match the linux version but it's hard to disambiguate what should be attributed to a better and leaner scheduler. |