November 30, 2010

calberto calberto
Lab Rat
18 posts

How many implicit thread?  (Windows mingw)

 

Someone know then Qt creates implicit threads? That is, for instance, I notice that using QTimer::singleShot() with a delay greater then zero create a new thread.

I have an application that create a QThread by its own and an implicit thread with the Windows multimedia timer, but the total count of the application thread is 4 (after the start of the multimedia timer). I’m quite sure I have only zero-delayed singleShot() timer (in two the form class constructor), then some startTimer()/timerEvent() both in some “designer-created” class and in some class defined and instantiated in .cpp file.

I expected to have one main thread, one multimedia timer thread and one worker thread, for a total of 3 against the actually 4.

Maybe the multimedia timer create more than one thread, but I thinks this is not the case since the number of threads is incremented by one (from 3 to 4) only then I start the timer.

Maybe there is a bug in my code, but so far I’m quite sure I create only one additional worker thread.

With the debugger I can easily identify the main thread, the worker and, once started, the multimedia one. The other 1 seems to be waiting in a Sleep or somewhere in the windows kernel (RrcBCacheFree). When debugging I have two more thread.

The GUI (win32-mingw) is composed by a QMainWindow with some docks and a QTabWidget for the central area. The tab uses some QTreeWidget (that, it seems to me, implicitly use timerEvent() to manages some updates). It doesn’t use the network of other particular resources.

4 replies

November 30, 2010

Tobias Hunger Tobias Hunger
Mad Scientist
3135 posts

I do not understand your problem. Is this just curiosity about where the threads you observe come from or are the threads triggering some problem for you?

November 30, 2010

Franzk Franzk
Lab Rat
830 posts

Sounds like the QtConcurrent thread pool…

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

December 1, 2010

calberto calberto
Lab Rat
18 posts
Tobias Hunger wrote:
I do not understand your problem. Is this just curiosity about where the threads you observe come from or are the threads triggering some problem for you?

Mainly curiosity. Apparently these threads don’t trigger any problem (I could have a bug somewhere and instantiate a class twice, but I already check for that and it seems this is not the case).

My application is soft real-time (as far it is possible with Windows XP), the worker thread is at time critical priority and it seems it is not affected by the phantom thread. Anyway, I would like to know the usage of the resources.

December 1, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

calberto, Qt itself creates threads sometimes (for example when you are using QtScript), but as you say your app should not be affected much by such threads. Most of time they are in sleep.

 
  ‹‹ How to distribute QtSql APP      QT 4.7.0 - Windows - Cannot find QSslSocket after recompiling static QT ››

You must log in to post a reply. Not a member yet? Register here!