guild icon
Toit
#Pause instead of sleep?
Thread channel in help
addshore
addshore 07/30/2025 03:53 PM
Is there a way to sleep, but not allowed other tasks to run during that period?
bitphlipphar
bitphlipphar 07/30/2025 03:54 PM
For a specific container? Not the entire system?
addshore
addshore 07/30/2025 03:56 PM
So, we are doing some low level stepper motor stuff (and debugging things).
We are manually controlling steps with GPIo pins currently, pulsing one of them to control the steps. And I want consistent pauses between them, but I'm guessing my use of sleep is causing other containers to do stuff as I'm currently running jaguar?
bitphlipphar
bitphlipphar 07/30/2025 03:56 PM
How long do you need to pause?
addshore
addshore 07/30/2025 03:57 PM
We would be happy with a second for now :🙂:
bitphlipphar
bitphlipphar 07/30/2025 03:58 PM
So you could do something like this: Change the priority of your running process to be higher than other things and do a busy-wait loop until enough time has passed ideally using Time.monotonic-us --since-wakeup.(edited)
bitphlipphar
bitphlipphar 07/30/2025 04:00 PM
You can change the priority of your process using something like Process.current.priority = Process.PRIORITY-HIGH.
bitphlipphar
bitphlipphar 07/30/2025 04:01 PM
You'll be fairly unresponsive while you loop.
addshore
addshore 07/30/2025 04:02 PM
Just realized that just running the thing with Jag disable makes a hell of a difference already!
bitphlipphar
bitphlipphar 07/30/2025 04:03 PM
So maybe just running your container with a higher priority would help?
👍1
bitphlipphar
bitphlipphar 07/30/2025 04:03 PM
When your sleep times out, you'll be more important than Jaguar, so it probably would improve things considerably.
bitphlipphar
bitphlipphar 07/30/2025 04:22 PM
fancy-sleep duration/Duration -> none: deadline-us := (Time.monotonic-us --since-wakeup) + duration.in-us while true: remaining-us := deadline-us - (Time.monotonic-us --since-wakeup) if remaining-us <= 0: return // Don't sleep when too close to the deadline. sleep-us := remaining-us - 100_000 // Don't sleep for too little time. if sleep-us >= 20_000: sleep --ms=(sleep-us / 1_000)
12 messages in total