Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
bc0290a7
Commit
bc0290a7
authored
5 years ago
by
Rick Yiu
Committed by
Gerrit Code Review
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Implement the ThreadPrioritySetter interface"
parents
267b83e7
a7612150
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/java/com/android/internal/os/RuntimeInit.java
+31
-0
31 additions, 0 deletions
core/java/com/android/internal/os/RuntimeInit.java
with
31 additions
and
0 deletions
core/java/com/android/internal/os/RuntimeInit.java
+
31
−
0
View file @
bc0290a7
...
...
@@ -35,6 +35,7 @@ import com.android.internal.logging.AndroidConfig;
import
com.android.server.NetworkManagementSocketTagger
;
import
dalvik.system.RuntimeHooks
;
import
dalvik.system.ThreadPrioritySetter
;
import
dalvik.system.VMRuntime
;
import
libcore.content.type.MimeMap
;
...
...
@@ -204,6 +205,7 @@ public class RuntimeInit {
*/
public
static
void
preForkInit
()
{
if
(
DEBUG
)
Slog
.
d
(
TAG
,
"Entered preForkInit."
);
RuntimeHooks
.
setThreadPrioritySetter
(
new
RuntimeThreadPrioritySetter
());
RuntimeInit
.
enableDdms
();
// TODO(b/142019040#comment13): Decide whether to load the default instance eagerly, i.e.
// MimeMap.setDefault(DefaultMimeMapFactory.create());
...
...
@@ -216,6 +218,35 @@ public class RuntimeInit {
MimeMap
.
setDefaultSupplier
(
DefaultMimeMapFactory:
:
create
);
}
private
static
class
RuntimeThreadPrioritySetter
implements
ThreadPrioritySetter
{
// Should remain consistent with kNiceValues[] in system/libartpalette/palette_android.cc
private
static
final
int
[]
NICE_VALUES
=
{
Process
.
THREAD_PRIORITY_LOWEST
,
// 1 (MIN_PRIORITY)
Process
.
THREAD_PRIORITY_BACKGROUND
+
6
,
Process
.
THREAD_PRIORITY_BACKGROUND
+
3
,
Process
.
THREAD_PRIORITY_BACKGROUND
,
Process
.
THREAD_PRIORITY_DEFAULT
,
// 5 (NORM_PRIORITY)
Process
.
THREAD_PRIORITY_DEFAULT
-
2
,
Process
.
THREAD_PRIORITY_DEFAULT
-
4
,
Process
.
THREAD_PRIORITY_URGENT_DISPLAY
+
3
,
Process
.
THREAD_PRIORITY_URGENT_DISPLAY
+
2
,
Process
.
THREAD_PRIORITY_URGENT_DISPLAY
// 10 (MAX_PRIORITY)
};
@Override
public
void
setPriority
(
int
priority
)
{
// Check NICE_VALUES[] length first.
if
(
NICE_VALUES
.
length
!=
(
1
+
Thread
.
MAX_PRIORITY
-
Thread
.
MIN_PRIORITY
))
{
throw
new
AssertionError
(
"Unexpected NICE_VALUES.length="
+
NICE_VALUES
.
length
);
}
// Priority should be in the range of MIN_PRIORITY (1) to MAX_PRIORITY (10).
if
(
priority
<
Thread
.
MIN_PRIORITY
||
priority
>
Thread
.
MAX_PRIORITY
)
{
throw
new
IllegalArgumentException
(
"Priority out of range: "
+
priority
);
}
Process
.
setThreadPriority
(
NICE_VALUES
[
priority
-
Thread
.
MIN_PRIORITY
]);
}
}
@UnsupportedAppUsage
protected
static
final
void
commonInit
()
{
if
(
DEBUG
)
Slog
.
d
(
TAG
,
"Entered RuntimeInit!"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment