Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-05

RE: Free Pascal version 1.0.6 released

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Schnell

== Ursprüngliche Mitteilung von am 6.05.02 23:14

Now that v1.0.6 is released, work will be concentrated on v1.1 of the compiler, which will eventually form the v1.2 release. multithreading...

=== Kommentar von (Michael Schnell) am 7.05.02 09:04

I did an implementation of TThreads for Free Pascal some months ago. It does work, but we can not use several FP features of OPs, as things like creating an instance of a class, long strings and such things that use the memory management are not thread-safe.

We tried to make the heap management thread save (without using my TThread class, even without using classes at all, just using clone() to create a new process) by introducing a locking mechanism, but in the end failed due to still unknown reasons.

We were able to make the same project run safe when we set the clone flags _not_ to share memory between the processes. Of course we could not use nice and easy inter thread communication like TThreadList (which is very easily derived from TList)

Can/should I work with you on the implementation of multithreadding in FP ?

-Michael Schnell, Lumino GmbH,
Oppumer Straße 81-83, D-47799 Krefeld, Germany.
http://www.lumino.de
Tel.: +49-2151-8196-72 Fax: +49-2151-8196-66-72

Reply by email

Michael Van Canneyt
to Michael Schnell
Michael Schnell wrote 22 lines
== Urspr�ngliche Mitteilung von am 6.05.02 23:14 >Now that v1.0.6 is released, work will be concentrated on v1.1 of the >compiler, which will eventually form the v1.2 release. > >multithreading... === Kommentar von (Michael Schnell) am 7.05.02 09:04 I did an implementation of TThreads for Free Pascal some months ago. It does work, but we can not use several FP features of OPs, as things like creating an instance of a class, long strings and such things that use the memory management are not thread-safe. We tried to make the heap management thread save (without using my TThread class, even without using classes at all, just using clone() to create a new process) by introducing a locking mechanism, but in the end failed due to still unknown reasons. We were able to make the same project run safe when we set the clone flags _not_ to share memory between the processes. Of course we could not use nice and easy inter thread communication like TThreadList (which is very easily derived from TList)

Not sharing the memory defies the idea of threads of course.

Can/should I work with you on the implementation of multithreadding in FP ?

The 1.0.6 branch will not be updated to contain thread-safe routines.

There is a framework for this already in the 1.1 series; It should be basically working for Win32, for Linux one or two functions should still be implemented. You can contact me or Florian Klaempfl for more details.

Basically what is still missing is a semaphore mechanism (for EnterCriticalSection/LeaveCriticalSection routines), and the allocation of thread variables. But that must be implemented using assembler instructions. I had a look at pthreads, and we're now at a point where we should be able to settle the matter.

But since (as always) there is a lack of time, you're welcome to help out.

Michael.

Reply by email

Jonas Maebe
to Michael Schnell: == Ursprüngliche Mitteilung von am 6.05.02 23:14 === Kommentar von (Michael Schnell)…
Michael Schnell wrote 7 lines
We tried to make the heap management thread save (without using my TThread class, even without using classes at all, just using clone() to create a new process) by introducing a locking mechanism, but in the end failed due to still unknown reasons.

You can always implement a heap manager that that uses the OS's memory allocation routines (those are normally thread-safe). See the cmem unit in the packages as an example (I think it should work for both Linux and win32)

Jonas

Reply by email