Re: [fpc-pascal] Sleep(30) is not reliable?
On 24/01/18 16:15, AlexeyT wrote: In Lazarus component EControl I call Sleep(30) to wait when timer tick work is done. while FBusy do Sleep(30); and app loops forever now in sleep(). procedure Sleep(milliseconds: Cardinal);Var timeout,timeoutresult : TTimespec; res: cint;begin timeout.tv_sec:=milliseconds div 1000; timeout.tv_nsec:=1000*1000*(milliseconds mod 1000); repeat res:=fpnanosleep(@timeout,@timeoutresult); timeout:=timeoutresult; until (res<>-1) or (fpgeterrno<>ESysEINTR);end; It is fpc 3.0.2. IDE Lazarus shows long loop inside this 'repeat'. i waited 10-20seconds. What happens if you put an Application.ProcessMessages in there? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sleep(30) is not reliable?
On Wed, 24 Jan 2018, AlexeyT wrote: In Lazarus component EControl I call Sleep(30) to wait when timer tick work is done. while FBusy do Sleep(30); How is the FBusy set to false ? You should add an Application.Processmesages in this loop, otherwise the timer tick (or whatever event sets FBusy to false) will never happen ?. while FBusy do begin Sleep(30); Application.ProcessMessages; end; Michael. and app loops forever now in sleep(). procedure Sleep(milliseconds: Cardinal); Var timeout,timeoutresult : TTimespec; res: cint; begin timeout.tv_sec:=milliseconds div 1000; timeout.tv_nsec:=1000*1000*(milliseconds mod 1000); repeat res:=fpnanosleep(@timeout,@timeoutresult); timeout:=timeoutresult; until (res<>-1) or (fpgeterrno<>ESysEINTR); end; It is fpc 3.0.2. IDE Lazarus shows long loop inside this 'repeat'. i waited 10-20seconds. -- Regards, Alexey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sleep(30) is not reliable?
Hi, On Wed, 24 Jan 2018, AlexeyT wrote: > Details: > Ubuntu 17.4 x64; Lazarus 1.9 trunk, fpc 3.0.2. > I see IDE call stack like this when i pause app (during loop forever) > Can you run strace on your app, to discover what are the nanosleep syscalls entry values and what are the return values? That should reveal if there's a flaw in that SysUtils sleep code loop. But the other possibility would be that your code never sets FBusy to false, if it calls Sleep() in a loop? Charlie___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sleep(30) is not reliable?
Details: Ubuntu 17.4 x64; Lazarus 1.9 trunk, fpc 3.0.2. I see IDE call stack like this when i pause app (during loop forever) SYSTEM_$$_FPSYSCALL$INT64$INT64$$INT64 0041E7E0 55 push %rbp 0041E7E1 4889e5 mov %rsp,%rbp 0041E7E4 488d6424f0 lea -0x10(%rsp),%rsp 0041E7E9 4889f8 mov %rdi,%rax 0041E7EC 4889f7 mov %rsi,%rdi 0041E7EF 0f05 syscall 0041E7F1 483d01f0 cmp $0xf001,%rax 0041E7F7 7215 jb 0x41e80e0041E7F9 48f7d8 neg %rax 0041E7FC 4889c7 mov %rax,%rdi 0041E7FF e87cff callq 0x41e780 0041E804 48b8 movabs $0x,%rax 0041E80E c9 leaveq 0041E80F c3 retq SYSTEM_$$_FPSYSCALL$INT64$INT64$INT64$$INT64 0041E810 55 push %rbp 0041E811 4889e5 mov %rsp,%rbp 0041E814 488d6424f0 lea -0x10(%rsp),%rsp 0041E819 4889f8 mov %rdi,%rax 0041E81C 4889f7 mov %rsi,%rdi 0041E81F 4889d6 mov %rdx,%rsi 0041E822 0f05 syscall 0041E824 483d01f0 cmp $0xf001,%rax < here IDE stops Alexey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Sleep(30) is not reliable?
In Lazarus component EControl I call Sleep(30) to wait when timer tick work is done. while FBusy do Sleep(30); and app loops forever now in sleep(). procedure Sleep(milliseconds: Cardinal); Var timeout,timeoutresult : TTimespec; res: cint; begin timeout.tv_sec:=milliseconds div 1000; timeout.tv_nsec:=1000*1000*(milliseconds mod 1000); repeat res:=fpnanosleep(@timeout,@timeoutresult); timeout:=timeoutresult; until (res<>-1) or (fpgeterrno<>ESysEINTR); end; It is fpc 3.0.2. IDE Lazarus shows long loop inside this 'repeat'. i waited 10-20seconds. -- Regards, Alexey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal