PDA

View Full Version : QThread set scheduling policy



corrado1972
8th June 2013, 12:43
Is it possible to set scheduling policy in Qthread ?
Im using ubuntu, and I'm confident that qthreads are implemented using pthreads, but I don't know how to acces pthreads attribs for advanced tuning like setting scheduling policy.

With posix classes I would use:


#include <pthread.h>
pthread_attr_t attrib;
pthread_attr_init(&attrib);
int ret = pthread_attr_setschedpolicy(&attrib, SCHED_RR);

but I don't figure out how to do this with Qthreads.

anda_skoa
8th June 2013, 15:22
You will have to patch Qt, more precisely QThread::start() in corelib/thread/qthread_unix.cpp

Cheers,
_

corrado1972
8th June 2013, 17:23
thanks for the advice, although I'm in doubt about this: I wonder how to expose in QThread attrib struct. The regular way should be to provide an accessor to internal data. If I modify the start() call, I I have to pass as argument the attribs struct address, and inside the method start() i should manipulate the scheduler, that isn't correct from the encapsulation point of view. Isn't it?
So, after this brainstorming, I can reformulate my question to you: how to modify qthread sources (POSIX part) in order to encapsulate the scheduling policies?

anda_skoa
9th June 2013, 22:24
Hmm, you could add another enum.

Cheers,
_