diff options
| author | 2020-01-17 11:45:03 -0800 | |
|---|---|---|
| committer | 2020-01-17 11:45:03 -0800 | |
| commit | 13839cfe415d9dcb5d850ad6dc1fdbb92b19d345 (patch) | |
| tree | 467165fc179eafe556caeab6c9b8249101c20bb7 | |
| parent | 1e60d390af32802349b7aea9a6f1d4a72f10d63d (diff) | |
| parent | 80993a6e60ed691651d2bf80d203df762afbd37e (diff) | |
Adjust Java Language thread priority in new processes.
am: 80993a6e60
Change-Id: I9fc2a68681eb3f39980c45f707581c3a19cdf0d4
| -rw-r--r-- | core/java/com/android/internal/os/Zygote.java | 3 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteConnection.java | 3 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 18 |
3 files changed, 21 insertions, 3 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index 84ff5b88a3ae..55a70284a5bf 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -654,6 +654,9 @@ public final class Zygote { // End of the postFork event. Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); + // Set the Java Language thread priority to the default value for new apps. + Thread.currentThread().setPriority(Thread.NORM_PRIORITY); + return ZygoteInit.zygoteInit(args.mTargetSdkVersion, args.mDisabledCompatChanges, args.mRemainingArgs, diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index 2666d5278a90..4c5bb2ade0aa 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -487,6 +487,9 @@ class ZygoteConnection { Zygote.setAppProcessName(parsedArgs, TAG); + // Set the Java Language thread priority to the default value for new apps. + Thread.currentThread().setPriority(Thread.NORM_PRIORITY); + // End of the postFork event. Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); if (parsedArgs.mInvokeWith != null) { diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index f870d0a9257d..4a33bc2f252a 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -518,6 +518,9 @@ public class ZygoteInit { } } + // Set the Java Language thread priority to the default value for the system server. + Thread.currentThread().setPriority(Thread.NORM_PRIORITY); + if (parsedArgs.mInvokeWith != null) { String[] args = parsedArgs.mRemainingArgs; // If we have a non-null system server class path, we'll have to duplicate the @@ -825,13 +828,22 @@ public class ZygoteInit { return result; } + /** + * This is the entry point for a Zygote process. It creates the Zygote server, loads resources, + * and handles other tasks related to preparing the process for forking into applications. + * + * This process is started with a nice value of -20 (highest priority). All paths that flow + * into new processes are required to either set the priority to the default value or terminate + * before executing any non-system code. The native side of this occurs in SpecializeCommon, + * while the Java Language priority is changed in ZygoteInit.handleSystemServerProcess, + * ZygoteConnection.handleChildProc, and Zygote.usapMain. + * + * @param argv Command line arguments used to specify the Zygote's configuration. + */ @UnsupportedAppUsage public static void main(String argv[]) { ZygoteServer zygoteServer = null; - // Set the initial thread priority to the "normal" value. - Thread.currentThread().setPriority(Thread.NORM_PRIORITY); - // Mark zygote start. This ensures that thread creation will throw // an error. ZygoteHooks.startZygoteNoThreadCreation(); |