[Lazarus] Threads in Lazarus code base
Michael Schnell
mschnell at lumino.de
Tue Sep 21 10:51:47 CEST 2010
On 09/21/2010 10:34 AM, Michael Fuchs wrote:
> Am 21.09.2010 09:59, schrieb Michael Schnell:
>> Usually any type of "parallel" implementation in a language or a library
>> would limit the count of spawned tasks to a number lower than the count
>> of CPUs available.
>
> You mean n-1 parallel tasks for n CPUs? That will be very bad on a
> single core machine. ;)
Not at all :)
n-1 additional parallel tasks will be spawned. The tasks to do will
dynamically be assigned to those and be assigned another one it one is
done. I suppose if appropriate (i.e. if it needs to wait for result due
to a "future variable" or a similar restriction, the main thread will be
assigned the tasks as well.
The nice thing about syntax concepts such as "parallel" and "future" is
that the user does not _need_ to deal with the multi-threading
complexity, even though it does not prevent the user from committing
huge mistakes when he in fact does (e.g. by writing to variables
commonly used by multiple parallel loop runs, which can be done
implicitly and thus hard to detect).
-Michael
More information about the Lazarus
mailing list