[fpc-pascal] RE: Threads executing in sequence instead of parallel

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Sep 29 19:00:08 CEST 2006

Thanks Jason - I don't recall you mentioning what platform you are
working on, but I gather in is some *nix platform.  The only thing you
just proofed with your post is - threading is not working correctly!

There shouldn't be a need for workarounds like suspending threads to
get others to work. The whole point of threads, is let them run all at
once in parallel.  Delphi does it, Kylix does it, FPC under win32 does
it!  Linux doesn't!  Instead of figuring out a workaround, rather
submit a bug report with an example.

My apps follow the fire and forget method and it works 100% under
Delphi and Kylix, but since I moved to FPC, this is causing more and
more headaches.  Take on of my apps as an example.  I start my app,
and get to the login prompt.  While I am logging in, the app fires off
a thread to populate the lookup tables from a database, another thread
loads the application/system settings.  I also have another thread
that does logging - to file, to console, to a log window or any
combination of the three.  Each logging type is another thread, and
letting them run is serial is not a solution. Neither is playing
round-robin with all those threads to suspend one, to get the next one
in the queue to run.  How does that take advantage of multiprocessor
pc's or hyper threading or the new Core 2 Due processors? It doesn't.

Make no mistake, I love Free Pascal too and it offers a lot for a
great price.  All my previous posts, was just me trying to debug the
threading and pinpoint the problem. All to make it easier for the
person that knows the internals of FPC to fix something like that. I
am not a Compiler developer, I'm a Application developer.  ;-)   After
all my tests, I now know it is a bug, and submitted a report on Mantis
with two demos.

Now the interesting part is how did I get started with all this
threading business under FPC.? :-)
I needed to port a Kylix app to FPC and wanted to take advantage of
threads as the app lends itself perfectly for threading.  I thought to
test the qualify of FPC threading support, I would first port one or
two of the top 10 threading applications that was submitted to Borland
in a Threading Contest which Borland held in 2002. Search Borland's
CodeCentral or I could post the link.  There are some good threading
examples available.  :-)

On 29/09/06, Jason P Sage <jasonpsage at jegas.org> wrote:
> Hi - I read enough of this topic to compel me to respond.
> I have been working with Multi-threading in Free Pascal for a only a month
> or so now and I learned a great deal - and I have resigned to accepting
> there are design considerations I have had to adopt to get the results I
> wanted - that some times seem a bit less than ideal - but the pay offs have
> been wonderful. Let me digress a little...
> First of all - THREADS running in a SERIAL fashion... Yup...

More information about the fpc-pascal mailing list