PDA

View Full Version : Threading on MAC OSX in Lazarus/FPC



jdarling
04-04-2008, 08:45 PM
Ok, I've done my research and it appears that threading isn't supported on a Mac by FPC/Lazarus :(. Reading it appeared that I should setup my own TThread structure. I modified my code to use MPCreateTask and MPTerminateTask but it still crashes when the thread spins up :(.

Any ideas on how to properly spin up and execute a thread on a MAC?

You can see my attempt in the ATerm demo I posted in the macClient.inc file. Download at: http://www.eonclash.com/ in case you don't want to go searching for it :)

savage
04-04-2008, 10:54 PM
So are you saying that TThread does not work under FreePascal under Mac OS X?

cronodragon
05-04-2008, 12:45 AM
I have found myself the LCL doesn't work well with threads in Linux and Windows :P Sorry to read that about Mac :(

jdarling
05-04-2008, 04:02 PM
So are you saying that TThread does not work under FreePascal under Mac OS X?

Actually, thats exactly what I'm saying. No one has ever finished the underlying threading model for Mac's :(. After reading in the Mac Developers stuff and reading the threads on lazarus.freepascal.org I found the MP commands. Problem is, they don't seem to work either :(.

Just a matter of figuring out exactly what I have to do to get threading to work on the Mac.

Any ideas?

savage
05-04-2008, 10:46 PM
Is this the doc you are referring to...
http://developer.apple.com/macosx/multithreadedprogramming.html

savage
12-04-2008, 08:19 AM
I wrote a small example using TThread on Mac OS X and initially it did not work because I did not have "cthread" in my uses clause in the project file. After adding cthread ( you may want to stick and IFDEF around if you are doing cross-platform stuff ) to my .lpr file the threading example worked fine.

Now it was fairly simple, so your mileage may vary, but it did work.
I hope this helps.

Almindor
27-05-2008, 11:29 AM
Threading works on MacosX for years (bugs not withstanding) and LCL is exactly like VCL not thread safe.