[fpc-pascal] Why is cthreads unit not included by default

Michael Van Canneyt michael at freepascal.org
Thu Aug 27 12:20:52 CEST 2009



On Thu, 27 Aug 2009, Graeme Geldenhuys wrote:

> Hi,
>
> I first asked this question in the Lazarus mailing list, but was told it
> may be more appropriate here. When you create a new project in Lazarus,
> the default uses clause in the *.lpr file looks as follows:
>
> ---------------
> uses
>  {$IFDEF UNIX}{$IFDEF UseCThreads}
>  cthreads,
>  {$ENDIF}{$ENDIF}
>  Classes;
> ---------------
>
> Question 1:
>  Is there an alternative implementation of multi-threading support for
> Unix-type systems -- other than the cthreads unit?

No.

>
>
> Question 2:
>  If not, then why do we have the extra "IFDEF UseCThreads" define in
> the uses clause?

To be able to disable it ?

> Mattias mentioned that when cthreads unit is included, all string access
> needs critial sections which will slow down string access for any
> unix-type OS.
>
> Now because under Windows, threading support is on by default, does that
> mean the same program will run faster under Linux than under Windows?
> Why is threading enabled by default under Windows and not under other
> platforms?

Because it creates a dependency on the C library, which 
is not always wanted. For Lazarus programs, the dependency exists
anyway, so it does not make a lot of sense to have the define.

Michael.



More information about the fpc-pascal mailing list