[fpc-devel] Light weight threads for FPC

Florian Klaempfl florian at freepascal.org
Fri Dec 14 11:50:07 CET 2007


Mattias Gaertner schrieb:
> On Fri, 14 Dec 2007 10:29:59 +0100
> Michael Schnell <mschnell at lumino.de> wrote:
> 
>> Mattias Gaertner wrote:
>>> Has someone already created a unit for light weight threads?
>>>   
>> What do you mean by "light weight threads" ? How can it get "lighter" 
>> than TThread, that offers close to no built-in
>> "comfort"-functionality ?
> 
> Hehe. I mainly choose the term to provoke.
> 
> TThread is a class and has more functionality than needed, but misses
> the ability to work in teams. For many parallel algorithms you don't
> need events, priority or synchronize. But you need to easily and fast
> start a set of threads with IDs 0..N. N can be computed from the
> number of cores or IO queues. But many algorithms simply compute N from
> the input size (e.g. N=n/log(n)). A pool with threads, each running and
> eating tasks in loops are 'lighter' than starting N real threads.
> For example starting a procedure "100 times in parallel" means on a dual
> core: Two threads execute the procedure 50 times. This is much lighter
> than 100 TThreads. And if one of the threads 'runs slower' than it will automatically
> load balance.

That's why I proposed this thread pool approach :)



More information about the fpc-devel mailing list