Results 1 to 3 of 3

Thread: My thread is using 100% of the CPU!!!

  1. #1
    Join Date
    Jun 2013
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default My thread is using 100% of the CPU!!!

    Hello,

    I've decided to separate my tcp listener's code from the GUI with QTthread. I've implemented this listener, standalone previously and it's not using any resources whatsoever. However, when I run the same code from a qt thread it's using 100% of a single core. I've tried using priorities but it didn't change anything. The listener is implemented with while(1). Same code compiled as a standalone console exe(no qt) uses 0% CPU. I've used both QtConcurrent and QThread, the result is the same. Any suggestions?

  2. #2
    Join Date
    Feb 2013
    Location
    India
    Posts
    153
    Thanks
    27
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: My thread is using 100% of the CPU!!!

    LOOP will freeze all the activity of the parent code.
    As you said that you use while(1) . but if you continuously listening then implement msSleep method of thread which will sleep your thread for some time . which cause a continuous execution of thread without interrupting other thread or process.

    HAVE A LOOK AT QThread
    CHEERS AND THE PROBLEM IS RESOLVED...

  3. The following user says thank you to karankumar1609 for this useful post:

    cdarwin (20th June 2013)

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

    Default Re: My thread is using 100% of the CPU!!!

    Quote Originally Posted by cdarwin View Post
    I've decided to separate my tcp listener's code from the GUI with QTthread.
    Hmm... why?

    The listener is implemented with while(1)
    That's not a listener. That's a constant bugger to the CPU.
    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.


Similar Threads

  1. Replies: 1
    Last Post: 25th October 2012, 15:10
  2. Replies: 11
    Last Post: 12th September 2012, 16:25
  3. Replies: 1
    Last Post: 4th September 2012, 14:13
  4. Replies: 1
    Last Post: 28th March 2012, 18:58
  5. Replies: 5
    Last Post: 22nd February 2011, 21:21

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.