On Tue, 5 Oct 2021 10:22:44 +0200 (CEST), Michael Van Canneyt via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
>> My program in Lazarus *is* a "simple program" and it has no GUI components. >> >> I never even looked at the implementation of CheckSynchronize()... >> It was just given in another thread when I was working on the port from >> Delphi >> to Linux and thus from the Windows GUI environment to the non-GUI command >> line >> program environment. > >The name 'Gui thread' is misleading. It's simply the main program thread. > >If you want to use TThread.Synchronize then the call to CheckSynchronize is >needed. The LCL for GUI application simply calls it automatically for you. >In a non-GUI command-line program, you're responsible for calling it from >time to time. That is what I had learned back in beginning of this year when I was starting testing on actual hardware. Checksynchronize is needed in the main program loop in order for threads to fire off events etc. I use threads to handle serial port communications, and the threads should be disposed of after use... Now I have done some more investigations and I am more confused by it... My service program runs at about 4% CPU usage as shown by top. This holds true for a long time after starting it (several idle days). But when a client connects to inspect data on the system the usage spikes when he commands some data display etc. But then goes back to the 4% or so. If the client enables a task to be executed then nothing really happens until that task starts on its set time. At that time the CPU usage raises from 4% to 11% and goes up/down a few % for the minutes it runs and then returns to an idle value of about 8%, which it never gets below after that. No matter how long I wait it is now stuck at that double value. So clearly something must be left behind after the task has finished... The question is: how to find what is still using CPU? -- Bo Berglund Developer in Sweden _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal