Timer with ThreadSleepNoEarlyWake #262
-
As part of a demo I have various threads that I want to sleep for a couple of seconds. The code is basically something like the following and is running the latest version of the dev container.
which was giving me a sleep of about 1 second. Having recently rebased my repo the timers are now returning more or less immediately. Turning on debugging in the scheduler I can see that they are waking early:
So digging in the code I saw there's now a flags argument to control this, but even with that set
although the log no longer shows that the thread is waking early
it still returns more or less immediately - I was expecting that telling it not to wake early would get me back to the previous behaviour. Clearly I'm missing something , can someone point me in the right direction please ? BTW I did try using |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 16 replies
-
This looks like a bug. I would expect your code to sleep for at least 1000 ticks (which, on Sonata, is 10s, so |
Beta Was this translation helpful? Give feedback.
-
It looks like timer.h has evolved quite a lot from the version I was previously working against. Looking at the code it looks like the reason this is jumping directly to the next timer is because threadHasNoPeers is evaluating to true, which means that nextTick gets set to DistantFuture and the clock seems to then jump directly to the value for the timer rather that going though the ticks inbetween ? If I force threadHasNoPeers to false then I get the timers working in realtime (rather than lunchtime). |
Beta Was this translation helpful? Give feedback.
-
Yep - ibex sim works fine ;-) Thanks for all the patience and explanations |
Beta Was this translation helpful? Give feedback.
@rmn30 - Running on ibex if fine in this case ;-)