From 648bf773b1aa759a40d8609039c44f9dce31da61 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 21 Jun 2011 13:51:04 +0200 Subject: use RoundRobin scheduler by default on QNX otherwise drawn intensive apps will hog the cpu and make the system appear frozen Merge-request: 1259 Reviewed-by: Harald Fernengel --- src/corelib/kernel/qcoreapplication.cpp | 16 ++++++++++++++++ src/corelib/thread/qthread_unix.cpp | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 7694a0f..c818ffc 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -98,6 +98,11 @@ # include #endif +#ifdef Q_OS_QNX +# include +# include +#endif + QT_BEGIN_NAMESPACE class QMutexUnlocker @@ -353,6 +358,17 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint qt_application_thread_id = QThread::currentThreadId(); #endif +#ifdef Q_OS_QNX + // without Round Robin drawn intensive apps will hog the cpu + // and make the system appear frozen + int sched_policy; + sched_param param; + if (pthread_getschedparam(0, &sched_policy, ¶m) == 0 && sched_policy != SCHED_RR) { + sched_policy = SCHED_RR; + pthread_setschedparam(0, sched_policy, ¶m); + } +#endif + // note: this call to QThread::currentThread() may end up setting theMainThread! if (QThread::currentThread() != theMainThread) qWarning("WARNING: QApplication was not created in the main() thread."); diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 839a396..765969e 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -479,6 +479,11 @@ void QThread::usleep(unsigned long usecs) // sched_priority is OUT only static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority) { +#ifdef Q_OS_QNX + // without Round Robin drawn intensive apps will hog the cpu + // and make the system appear frozen + *sched_policy = SCHED_RR; +#endif #ifdef SCHED_IDLE if (priority == QThread::IdlePriority) { *sched_policy = SCHED_IDLE; -- cgit v0.12