Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to create Thread on a Quad-core CPU?
Forum Updated to NodeBB v4.3 + New Features

How to create Thread on a Quad-core CPU?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thinh Nguyen
    wrote on last edited by
    #1

    Hi all,
    I'm a new by to Qt. Please help me to understand this problem:
    I have a hardware with Quad-core CPU and i use Qt to create an app for rendering image. When I click the button my app create a new windows then a new thread for rendering image. I click button 4 times and use htop to monitor CPU performance. I saw that only 1 core load 100% while others core <5%. I don't know why? It should be running parallel 4 threads on 4 cores and CPU on each core have to be the same value?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      How do you create new thread if the button is clicked?
      A new windows in your app does not mean a new thread.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • jsulmJ jsulm

        How do you create new thread if the button is clicked?
        A new windows in your app does not mean a new thread.

        T Offline
        T Offline
        Thinh Nguyen
        wrote on last edited by
        #3

        @jsulm is this correct?
        Window *window;
        window = new Window();
        window->show();
        in windows class constructor beside draw windows i alse call the thread:
        thread = new RenderThread(); (I declare thread in windows.h)
        in RenderThread Class contain run() function. So I think new thread will be created when i click the button.
        Here is my project: https://github.com/NguyenTrongThinh/Queuedcustomtype-.git

        1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Where do you start the thread? Creating an instance is not enough.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply
          0
          • jsulmJ jsulm

            Where do you start the thread? Creating an instance is not enough.

            T Offline
            T Offline
            Thinh Nguyen
            wrote on last edited by
            #5

            @jsulm I start thread in RenderThread constructor.

            1 Reply Last reply
            0
            • jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I would suggest to add some debug output (using qDebug() << "...";) to your code to see what really happens.
              I addition you could check whether your app really starts several threads (on Windows you can use "Process Explorer" from SysInternals suite.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved