summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2017-03-13 17:50:46 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-13 17:50:46 +0000
commit4c618d893350c14d215bc3b4eba74a50a5993e66 (patch)
treea8659421bab99abebb86e1ce3832bd699c3affe7 /core/java
parent3d61c893055d39f98149cd1d172948a5316c8c2b (diff)
parent55310df6bce616514d5958895c778f1c258b9b73 (diff)
Merge "Fix the reset of boosted zygote thread priority." am: 83aceea07d
am: 55310df6bc Change-Id: I91d20bc046b721456e0a141def790aeccfbd39a6
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/os/Zygote.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 59416dd06cdc..e065843a3961 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -100,6 +100,8 @@ public final class Zygote {
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
int[] fdsToIgnore, String instructionSet, String appDataDir) {
VM_HOOKS.preFork();
+ // Resets nice priority for zygote process.
+ resetNicePriority();
int pid = nativeForkAndSpecialize(
uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
fdsToIgnore, instructionSet, appDataDir);
@@ -144,6 +146,8 @@ public final class Zygote {
public static int forkSystemServer(int uid, int gid, int[] gids, int debugFlags,
int[][] rlimits, long permittedCapabilities, long effectiveCapabilities) {
VM_HOOKS.preFork();
+ // Resets nice priority for zygote process.
+ resetNicePriority();
int pid = nativeForkSystemServer(
uid, gid, gids, debugFlags, rlimits, permittedCapabilities, effectiveCapabilities);
// Enable tracing as soon as we enter the system_server.
@@ -173,6 +177,14 @@ public final class Zygote {
VM_HOOKS.postForkChild(debugFlags, isSystemServer, instructionSet);
}
+ /**
+ * Resets the calling thread priority to the default value (Thread.NORM_PRIORITY
+ * or nice value 0). This updates both the priority value in java.lang.Thread and
+ * the nice value (setpriority).
+ */
+ static void resetNicePriority() {
+ Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
+ }
/**
* Executes "/system/bin/sh -c &lt;command&gt;" using the exec() system call.