[fpc-pascal] My Linux service application consumes 10% CPU when idling - why?

Bo Berglund bo.berglund at gmail.com
Mon Oct 4 23:58:12 CEST 2021


On Mon, 04 Oct 2021 12:46:32 -0400, Dennis Lee Bieber via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

>
>	COMMENT: here you ask about a non-GU /service/ application, but in your
>prior post you gave a code snippet. It may just be a documentation flaw,
>but...
>
>-=-=-
>{ function to be called when gui thread is ready to execute method
>  result is true if a method has been executed
>}
>function CheckSynchronize(timeout : longint=0) : boolean;
>var
>  { method proc that is called to trigger gui thread to execute a
>method }
>  WakeMainThread : TNotifyEvent = nil;

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.

It was needed in the main loop in order for threads down inside the program to
be able to transfer their data into an event handler which is processing
incoming data.

Originally I had a sleep(5) inside the loop too, but I took that out when it was
clear that CheckSynchronize had a timeout argument (optional).

It is now close to midnight so I have to postpone any testing until tomorrow.


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list