Bug 663970 - Disable nice on systems that have multiple CPUs Part 1 of 2. r=dougt

--HG--
extra : rebase_source : 01a26264c473fcccd641925854752a7207c9dae2
This commit is contained in:
Gian-Carlo Pascutto 2011-06-16 11:50:00 -07:00
parent a8f34ba27d
commit 96a74c5f3c

View File

@ -101,6 +101,7 @@
#ifdef ANDROID
#include "gfxAndroidPlatform.h"
#include "AndroidBridge.h"
#include "nsSystemInfo.h"
#endif
#include "nsIClipboard.h"
@ -219,8 +220,17 @@ ContentParent::OnChannelConnected(int32 pid)
nice = atoi(relativeNicenessStr);
}
if (nice != 0) {
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
/* make the GUI thread have higher priority on single-cpu devices */
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
if (infoService) {
PRInt32 cpus;
nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
if (NS_FAILED(rv)) {
cpus = 1;
}
if (nice != 0 && cpus == 1) {
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
}
}
#endif
}