[fpc-devel] Light weight threads for FPC

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Dec 14 11:46:29 CET 2007


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.

So, I hope that someone already implemented some 'light weight'
threads for FPC and I can adapt and extend them.


Mattias



More information about the fpc-devel mailing list