Recent

Author Topic: How to get timers working on Linux Daemon  (Read 3343 times)

RynoJETLog

  • Newbie
  • Posts: 4
How to get timers working on Linux Daemon
« on: January 28, 2020, 03:38:29 pm »
Hi All,

We are looking for help to get timers working on a Linux Daemon.

We don't know where to put the "CheckSyncronize" into the main Daemon thread, because without "CheckSyncronize" the timer does not fire.

Is there anyone that got this to work? If so can you please advise how to get it working.

Thank you in advance.

Renat.Su

  • Full Member
  • ***
  • Posts: 208
    • Renat.Su
Re: How to get timers working on Linux Daemon
« Reply #1 on: January 28, 2020, 08:55:12 pm »
Doesn't TFPTimer work for Linux daemons?
In General I use the PRTLEvent variables in the TThread class in daemons for timing like
Code: Pascal  [Select][+][-]
  1. RTLeventWaitFor(aEvent, aDelayInMSec);

RynoJETLog

  • Newbie
  • Posts: 4
Re: How to get timers working on Linux Daemon
« Reply #2 on: January 30, 2020, 07:53:31 am »
Hi Renat,

Thank you for your response. We were actually using TTimer instead of TFPTimer.

It is working perfectly now.

Tesla2k

  • New member
  • *
  • Posts: 9
Re: How to get timers working on Linux Daemon
« Reply #3 on: August 23, 2021, 04:48:41 pm »
Can you maybe describe how to do it? I am trying exact the same.

RynoJETLog

  • Newbie
  • Posts: 4
Re: How to get timers working on Linux Daemon
« Reply #4 on: September 13, 2021, 10:47:12 am »
Hi Tesla2k,

I was trying to get either TfpTimer or TTimer to work for both Windows and Linux.

I end ended up using TfpTimer for linux only (unit:fptimer.pas) and TTimer for windows only(unit:extctrls.pas)

Hope this helps :-)

BobDog

  • Full Member
  • ***
  • Posts: 168
Re: How to get timers working on Linux Daemon
« Reply #5 on: September 13, 2021, 12:09:09 pm »

I sometimes use this for timing things.
I use win 10, don't know if this works on Linux.
Code: Pascal  [Select][+][-]
  1.  uses
  2.    SysUtils,DateUtils;
  3.  
  4. Function isprime(n:qword):boolean;
  5. var limit,i:qword;
  6. begin
  7. i:=6;
  8.  limit:=trunc(Sqrt(N))+1;
  9.     If (n=2) Or (n=3) Then exit(true);
  10.     If (n Mod 2 = 0) Then exit(false);
  11.     If (n Mod 3 = 0) Then exit(false);
  12.     while i<limit do
  13.     begin
  14.         If (N Mod (i-1) = 0) Then exit(false);
  15.         If (N Mod (i+1) = 0) Then exit(false);
  16.      i:=i+6;
  17.     end;
  18.     exit(true);
  19. End;
  20.  
  21.  var
  22.  StartTime,EndTime: TTime;
  23.  
  24.  
  25. begin
  26.  
  27. writeln('Please wait at least 10 seconds . . .');
  28. StartTime:=time;
  29. writeln(isprime(18446744073709551557));
  30. EndTime:=time;
  31. writeln('Time taken = ',MillisecondsBetween(EndTime, StartTime),' milliseconds');
  32. writeln('OK, press return to end . . .');
  33. readln;
  34. end.

 

TinyPortal © 2005-2018