Results 1 to 7 of 7

Thread: QThread 100% cpu usage on linux only

  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy QThread 100% cpu usage on linux only

    I have an app that runs several threads in the background. On windows and mac, it doesn't use any CPU usage when 'idle', but in linux it always sits at 100% all the time. Most of the threads are sitting on tryAcquire mutex locks with 250ms timeouts, and also have 250ms sleeps in the loops in the run function. Any ideas what could cause the CPU usage only on the linux host and any ideas on how to fix it?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QThread 100% cpu usage on linux only

    We'd have to see the code. As far as I remember on some systems the time spent in the sleep() call is treated as active cpu usage but I doubt this is what is causing the effect in your case. You'd have to see which threads are actually active.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QThread 100% cpu usage on linux only

    Please run your application under callgrind and see where your application spends all the time (you can use kcachegrind to display the data in more user-friendly format).

    By the way, why (in the first file) are you using tryAcquire() without even checking if you managed to acquire the semaphore or not? And also I see you intend to operate on some dialog from a worker thread - don't do it, it's forbidden, it will crash or deadlock your application.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread 100% cpu usage on linux only

    Weird...
    http://img42.imageshack.us/img42/6273/callmap.png
    Seems like LibSDL is the offender, or am I mis-reading something?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QThread 100% cpu usage on linux only

    More likely libasound. Just make sure you are tracing the proper thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread 100% cpu usage on linux only

    OK apparently this wasn't a Qt problem, sorry! Basically the issue is Ubuntu related. For some bizarre reason the libsdl package in linux decided to include the alsa based libsdl subsystem instead of the pulseaudio one. Switching from the alsa libsdl package to the pulseaudio one (libsdl1.2debian-pulseaudio) instantly fixed the problem and now it works perfectly. Whodathunkit..

Similar Threads

  1. QThread usage and exec()
    By smahnken in forum Qt Programming
    Replies: 10
    Last Post: 24th August 2008, 18:13
  2. CPU Time & Memory Usage in QThread or QProcess
    By Davidaino in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2008, 19:15
  3. QThread and signals (linux/UNIX signals not Qt Signals)
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 22:18
  4. Problem with QThread after linux rebuild
    By zlatko in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2006, 10:57
  5. Replies: 4
    Last Post: 10th May 2006, 22:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.