Raspberry Pi Thread.Sleep Causes 100% CPU Utilization

  1. 5 days ago

    Alex B

    Nov 7 Pre-Release Testers, Xojo Pro Canada
    Edited 5 days ago

    Hello everyone, got another weird one for you. Any ideas why Thread.Sleep would be causing 100% CPU usage?

    Basic Raspberry Pi 4 ARM desktop app with a thread added to Window1 with:

    Sub Run() Handles Run
      Do 
        System.DebugLog("Test!")
        Me.Sleep(1000)
      Loop
    End Sub

    and "Thread1.Run" in Window1's open event.

    Am I doing something wrong? I would expect this to basically do nothing? Funny thing is that running other stuff in for say the event loop, will cause the CPU usage to go down. I did check that it is actually waiting 1000ms with the call to System.DebugLog.

    Any help would be very much appreciated!

  2. Alex B

    Nov 7 Pre-Release Testers, Xojo Pro Canada

    It would also appear that Thread.Suspend does the same thing. The only way for me to sleep a thread is to kill it and then resume with a timer.

  3. Scott C

    Nov 7 Pre-Release Testers, Xojo Pro Vancouver, Canada

    What happens if you use App.SleepCurrentThread(1000) instead of Me.Sleep(1000)? Do you get a different result?

    Just curious.

  4. Alex B

    Nov 7 Pre-Release Testers, Xojo Pro Canada

    @Scott C What happens if you use App.SleepCurrentThread(1000) instead of Me.Sleep(1000)? Do you get a different result?

    Just curious.

    Same Issue sadly ;(

  5. Kevin G

    Nov 8 Pre-Release Testers, Xojo Pro Gatesheed, England

    This sounds like an issue I reported a long time ago against 32 bit Linux. The problem was worse on single core CPU but was still too high on multi-core CPUs. Unfortunately, I couldn't work around the problem.

    I've just checked Feedback and I cannot seem to find the case I logged (i'm sure Feedback isn't listing all cases).

    I did find this one from several years ago relating to MS-Windows so I guess there are some general gremlins with how sleep has been implemented.
    Feedback Case #30159

  6. Alex B

    Nov 8 Pre-Release Testers, Xojo Pro Canada

    @Kevin G This sounds like an issue I reported a long time ago against 32 bit Linux. The problem was worse on single core CPU but was still too high on multi-core CPUs. Unfortunately, I couldn't work around the problem.

    I've just checked Feedback and I cannot seem to find the case I logged (i'm sure Feedback isn't listing all cases).

    I did find this one from several years ago relating to MS-Windows so I guess there are some general gremlins with how sleep has been implemented.
    Feedback Case #30159

    After finding out that Thread.Suspend does the same thing, I took another look at the feedback and found this:

    Feedback Case #56420

or Sign Up to reply!