Permalink
Browse files

Revert "[droid] fixed linux thread priorities, do not mix xbmc priori…

…ty levels with system priority levels"

This reverts commit 02b7a0c.

The root cause may have been fixed by f5af55a.
  • Loading branch information...
1 parent a5c0972 commit d696127f207968816c02dc3e1fe806ba17529a01 Cory Fields committed Aug 6, 2012
Showing with 28 additions and 40 deletions.
  1. +14 −0 xbmc/linux/PlatformDefs.h
  2. +0 −16 xbmc/threads/Thread.h
  3. +14 −24 xbmc/threads/platform/pthreads/ThreadImpl.cpp
@@ -313,6 +313,20 @@ typedef struct _TIME_ZONE_INFORMATION {
#define TIME_ZONE_ID_STANDARD 1
#define TIME_ZONE_ID_DAYLIGHT 2
+// Thread
+#define THREAD_BASE_PRIORITY_LOWRT 15
+#define THREAD_BASE_PRIORITY_MAX 2
+#define THREAD_BASE_PRIORITY_MIN -2
+#define THREAD_BASE_PRIORITY_IDLE -15
+#define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN
+#define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1)
+#define THREAD_PRIORITY_NORMAL 0
+#define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX
+#define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1)
+#define THREAD_PRIORITY_ERROR_RETURN (0x7fffffff)
+#define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT
+#define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE
+
// Network
#define SOCKADDR_IN struct sockaddr_in
#define IN_ADDR struct in_addr
View
@@ -36,22 +36,6 @@
#include <mach/mach.h>
#endif
-// Thread
-#if !defined(WIN32)
-#define THREAD_BASE_PRIORITY_LOWRT 15
-#define THREAD_BASE_PRIORITY_MAX 2
-#define THREAD_BASE_PRIORITY_MIN -2
-#define THREAD_BASE_PRIORITY_IDLE -15
-#define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN
-#define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1)
-#define THREAD_PRIORITY_NORMAL 0
-#define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX
-#define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1)
-#define THREAD_PRIORITY_ERROR_RETURN (0x7fffffff)
-#define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT
-#define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE
-#endif
-
class IRunnable
{
public:
@@ -115,48 +115,39 @@ bool CThread::IsCurrentThread(const ThreadIdentifier tid)
int CThread::GetMinPriority(void)
{
- return -4;
- //return THREAD_PRIORITY_IDLE;
+ // one level lower than application
+ return -1;
}
int CThread::GetMaxPriority(void)
{
- return 4;
-// return THREAD_PRIORITY_HIGHEST;
+ // one level higher than application
+ return 1;
}
int CThread::GetNormalPriority(void)
{
- return THREAD_PRIORITY_NORMAL;
+ // same level as application
+ return 0;
}
bool CThread::SetPriority(const int iPriority)
{
- // iPriority is with respect to that defined in Thread.h
bool bReturn = false;
// wait until thread is running, it needs to get its lwp id
m_StartEvent.Wait();
CSingleLock lock(m_CriticalSection);
- if (!m_ThreadId)
- return false;
-
- // keep priority in bounds
- int prio = iPriority;
- if (prio >= GetMaxPriority())
- prio = GetMaxPriority();
- if (prio < GetMinPriority())
- prio = GetMinPriority();
-
- // nice level of application
- int appNice = getpriority(PRIO_PROCESS, getpid());
- // flip it with respect to the 'nice' levels (-20 to 19)
- prio = appNice - prio;
+ // get min prio for SCHED_RR
+ int minRR = GetMaxPriority() + 1;
- if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, prio) == 0)
- bReturn = true;
+ if (!m_ThreadId)
+ bReturn = false;
+ else if (iPriority >= minRR)
+ bReturn = SetPrioritySched_RR(iPriority);
+#ifdef RLIMIT_NICE
else
{
// get user max prio
@@ -189,6 +180,7 @@ bool CThread::SetPriority(const int iPriority)
else
if (logger) logger->Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
}
+#endif
return bReturn;
}
@@ -204,8 +196,6 @@ int CThread::GetPriority()
int appNice = getpriority(PRIO_PROCESS, getpid());
int prio = getpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId);
- // flip it with respect to the 'nice' levels (-20 to 19), so that
- // what is returned is with repect to that defined in Thread.h
iReturn = appNice - prio;
return iReturn;

0 comments on commit d696127

Please sign in to comment.