No doubt your sleep code works just fine.
I'm not saying the sleep command doesn't work.
I'm saying the sleep command doesn't release unused cpu cycles for other
threads/programs to use.
Apparently, if you want that behavior, you need to yield the cpu time
your process would otherwise take, that's done with a different kernel
function than sleep.
Alexander hit the nail on the head though with his solution, so I'm
satisfied that the original poster got what he needed, and I learned
something new about linux processes as well, which makes for a good all
around solution.
On 5/19/2021 6:02 AM, Mattias Gaertner wrote:
On Tue, 18 May 2021 18:37:38 -0400
Travis Siegel via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
Apparently, you can release cpu cycles, but it's with the sched_yield
(section 2 in the man pages), not the sleep command on linux.
What sleep command are you referring to?
What do you mean with cpu cycles?
Sleep works pretty well under Linux:
uses sysutils;
var i: integer;
begin
for i:=1 to 10000 do sleep(1);
end.
time ./test1
real 0m10,791s
user 0m0,021s
sys 0m0,018s
Mattias
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal