I have added threads to my application to speed up. In Windows and Linux it runs now about two times faster compared to a single thread version but not in MacOS. For an Intel Mac the processing speed is about the same. And for a M-processor Mac I get reports it is much slower then a single thread version.
Furthermore the System.CPUCount indicates one cpu in the debugger but the activity monitor indicated more 6 or 7 threads.
Has anybody an idea what could cause this poor performance and how to fix this? If have tried including cmem in the .lpr file but it doesn't help.
I do a lot of threaded testing and generally I get much more when threaded, but not in proportion to the number of threads (up to n performance cores or all cores).
But definitely where needed, threading boosts overall output.
Some odd things though ...
While InterlockedExcange( ZZZ,1)>0 do; // (Spinlock) will bog down the computer when multiple
//. instances (threads) of the same function are accessing that lock.
While InterlockedExcange( ZZZ,1)>0 do sleep(0); // will not improve things much, but
While InterlockedExcange( ZZZ,1)>0 do sleep(1); // will improve things a lot.
Maybe that's to be expected, but I don't have (I think) the same issues on x86 (MacOS) or ARM (RaspPi, Ultibo).
I haven't used CriticalSection for the above as such has a higher cycle cost in and out.