Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Is it OK for Time::HiRes::time() to report the time differently per thread?

by Anonymous Monk
on Apr 23, 2026 at 19:30 UTC ( [id://11167617]=note: print w/replies, xml ) Need Help??


in reply to Re: Is it OK for Time::HiRes::time() to report the time differently per thread?
in thread Is it OK for Time::HiRes::time() to report the time differently per thread?

Thank you very much, indeed, for pointing out about flaw in my code; I think I _do_ see what you mean by

It's possible to execute reach $_->down for @s; in one thread before reaching $s[ $id ]->down; in another thread

and, thus, the necessity of separate semaphore. Buggy code and flawed logic could cost me in the future. Thanks!!! Still, however, it won't happen in my SSCCE, nor in my real code, because of amount of time required for executing "payload" (and limited number of threads?). Here's result of one (out of about 10?) invocation of _exactly_ your code (the 1st one), it's the same issue:

first, 0 1.826 first, 2 1.834 first, 1 1.834 first, 3 1.836 next, 1 1.835 next, 0 1.829 next, 2 1.835 next, 3 1.836

However, using clock_gettime(CLOCK_MONOTONIC) it's looks like it's _always_ OK, and, FWIW, always the _same_ time reported for all of "next"'s.

first, 3 1.855 first, 1 1.856 first, 0 1.858 first, 2 1.867 next, 0 1.868 next, 1 1.868 next, 3 1.868 next, 2 1.868

Replies are listed 'Best First'.
Re^3: Is it OK for Time::HiRes::time() to report the time differently per thread?
by ikegami (Patriarch) on Apr 24, 2026 at 01:20 UTC

    No way. That output did not come from my code. I think you ran your old code by accident.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11167617]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2026-05-08 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.