Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Break a dependency on frameworks/base when building a host VM.

These aren't necessarily good abstractions, but they're no worse than what
we had, and having them factored out is a step in the right direction.

Change-Id: I5b839608317d2ca1ca54d8a38624fb686f2c37de
  • Loading branch information...
commit e6c0ef210ee6c62cf4c63d50c04f451d5fa505f5 1 parent 8c8d159
authored June 15, 2011
2  dalvikvm/Android.mk
@@ -61,7 +61,7 @@ ifeq ($(WITH_HOST_DALVIK),true)
61 61
         # OS X comes with all these libraries, so there is no need
62 62
         # to build any of them. Note: OpenSSL consists of libssl
63 63
         # and libcrypto.
64  
-        LOCAL_LDLIBS := -lffi -lssl -lcrypto -lz -lsqlite3
  64
+        LOCAL_LDLIBS := -lffi -lssl -lcrypto -lz
65 65
     else
66 66
         LOCAL_LDLIBS += -ldl -lpthread
67 67
         LOCAL_SHARED_LIBRARIES += libdvm libcrypto libicuuc libicui18n libssl
4  dexopt/Android.mk
@@ -43,7 +43,7 @@ endif
43 43
 
44 44
 LOCAL_SRC_FILES := $(local_src_files)
45 45
 LOCAL_C_INCLUDES := $(local_c_includes)
46  
-LOCAL_SHARED_LIBRARIES := $(local_shared_libraries) libcutils libexpat liblog libnativehelper libutils libz
  46
+LOCAL_SHARED_LIBRARIES := $(local_shared_libraries) libcutils libexpat liblog libnativehelper libz
47 47
 LOCAL_MODULE_TAGS := optional
48 48
 LOCAL_MODULE := dexopt
49 49
 
@@ -59,7 +59,7 @@ ifeq ($(WITH_HOST_DALVIK),true)
59 59
     LOCAL_SRC_FILES := $(local_src_files)
60 60
     LOCAL_C_INCLUDES := $(local_c_includes)
61 61
     LOCAL_SHARED_LIBRARIES := $(local_shared_libraries)
62  
-    LOCAL_STATIC_LIBRARIES :=  libcutils libexpat liblog libnativehelper libutils libz
  62
+    LOCAL_STATIC_LIBRARIES :=  libcutils libexpat liblog libnativehelper libz
63 63
     LOCAL_LDLIBS += -ldl -lpthread
64 64
     LOCAL_CFLAGS += -DANDROID_SMP=1
65 65
     LOCAL_MODULE_TAGS := optional
8  libnativehelper/Android.mk
@@ -34,7 +34,6 @@ shared_libraries := \
34 34
     libcrypto  \
35 35
     libicui18n \
36 36
     libicuuc   \
37  
-    libsqlite \
38 37
     libssl
39 38
 
40 39
 static_libraries := \
@@ -52,7 +51,7 @@ include $(CLEAR_VARS)
52 51
 LOCAL_SRC_FILES := $(src_files)
53 52
 LOCAL_C_INCLUDES := $(c_includes)
54 53
 LOCAL_STATIC_LIBRARIES := $(static_libraries)
55  
-LOCAL_SHARED_LIBRARIES := $(shared_libraries) libcutils libexpat liblog libstlport libutils libz
  54
+LOCAL_SHARED_LIBRARIES := $(shared_libraries) libcutils libexpat liblog libstlport libz
56 55
 LOCAL_MODULE_TAGS := optional
57 56
 LOCAL_MODULE := libnativehelper
58 57
 
@@ -74,11 +73,10 @@ ifeq ($(WITH_HOST_DALVIK),true)
74 73
     ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-x86)
75 74
         # OSX has a lot of libraries built in, which we don't have to
76 75
         # bother building; just include them on the ld line.
77  
-        LOCAL_LDLIBS := -lexpat -lssl -lz -lcrypto -licucore -lsqlite3
78  
-        LOCAL_WHOLE_STATIC_LIBRARIES += libutils
  76
+        LOCAL_LDLIBS := -lexpat -lssl -lz -lcrypto -licucore
79 77
     else
80 78
         LOCAL_SHARED_LIBRARIES := $(shared_libraries)
81  
-        LOCAL_STATIC_LIBRARIES := libcutils libexpat liblog libutils libz
  79
+        LOCAL_STATIC_LIBRARIES := libcutils libexpat liblog libz
82 80
     endif
83 81
 
84 82
     LOCAL_MODULE_TAGS := optional
4  unit-tests/Android.mk
@@ -34,7 +34,7 @@ LOCAL_C_INCLUDES += $(test_c_includes)
34 34
 LOCAL_MODULE := $(test_module)
35 35
 LOCAL_MODULE_TAGS := $(test_tags)
36 36
 LOCAL_SRC_FILES := $(test_src_files)
37  
-LOCAL_SHARED_LIBRARIES += libcutils libutils libdvm
  37
+LOCAL_SHARED_LIBRARIES += libcutils libdvm
38 38
 include $(BUILD_NATIVE_TEST)
39 39
 
40 40
 # Build for the host.
@@ -46,5 +46,5 @@ include $(BUILD_NATIVE_TEST)
46 46
 #LOCAL_MODULE_TAGS := $(test_tags)
47 47
 #LOCAL_SRC_FILES := $(test_src_files)
48 48
 #LOCAL_SHARED_LIBRARIES += libdvm libcrypto libssl libicuuc libicui18n
49  
-#LOCAL_WHOLE_STATIC_LIBRARIES += libcutils libutils liblog libdvm
  49
+#LOCAL_WHOLE_STATIC_LIBRARIES += libcutils liblog libdvm
50 50
 #include $(BUILD_HOST_NATIVE_TEST)
2  vm/Android.mk
@@ -112,7 +112,7 @@ ifeq ($(WITH_HOST_DALVIK),true)
112 112
     # Build as a WHOLE static library so dependencies are available at link
113 113
     # time. When building this target as a regular static library, certain
114 114
     # dependencies like expat are not found by the linker.
115  
-    LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libnativehelper libutils libz
  115
+    LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libnativehelper libz
116 116
 
117 117
     # The libffi from the source tree should never be used by host builds.
118 118
     # The recommendation is that host builds should always either
7  vm/Dvm.mk
@@ -188,6 +188,13 @@ LOCAL_SRC_FILES := \
188 188
 	test/TestHash.cpp \
189 189
 	test/TestIndirectRefTable.cpp
190 190
 
  191
+# TODO: this is the wrong test, but what's the right one?
  192
+ifeq ($(dvm_arch),arm)
  193
+  LOCAL_SRC_FILES += os/android.cpp
  194
+else
  195
+  LOCAL_SRC_FILES += os/linux.cpp
  196
+endif
  197
+
191 198
 WITH_COPYING_GC := $(strip $(WITH_COPYING_GC))
192 199
 
193 200
 ifeq ($(WITH_COPYING_GC),true)
85  vm/Thread.cpp
@@ -18,8 +18,7 @@
18 18
  * Thread support.
19 19
  */
20 20
 #include "Dalvik.h"
21  
-
22  
-#include "utils/threads.h"      // need Android thread priorities
  21
+#include "os/os.h"
23 22
 
24 23
 #include <stdlib.h>
25 24
 #include <unistd.h>
@@ -240,7 +239,6 @@ static void* internalThreadStart(void* arg);
240 239
 static void threadExitUncaughtException(Thread* thread, Object* group);
241 240
 static void threadExitCheck(void* arg);
242 241
 static void waitForThreadSuspend(Thread* self, Thread* thread);
243  
-static int getThreadPriorityFromSystem();
244 242
 
245 243
 /*
246 244
  * Initialize thread list and main thread's environment.  We need to set
@@ -1889,7 +1887,7 @@ bool dvmAttachCurrentThread(const JavaVMAttachArgs* pArgs, bool isDaemon)
1889 1887
      */
1890 1888
     JValue unused;
1891 1889
     dvmCallMethod(self, init, threadObj, &unused, (Object*)pArgs->group,
1892  
-        threadNameStr, getThreadPriorityFromSystem(), isDaemon);
  1890
+            threadNameStr, os_getThreadPriorityFromSystem(), isDaemon);
1893 1891
     if (dvmCheckException(self)) {
1894 1892
         LOGE("exception thrown while constructing attached thread object");
1895 1893
         goto fail_unlink;
@@ -3075,89 +3073,12 @@ Thread* dvmGetThreadByThreadId(u4 threadId)
3075 3073
     return thread;
3076 3074
 }
3077 3075
 
3078  
-
3079  
-/*
3080  
- * Conversion map for "nice" values.
3081  
- *
3082  
- * We use Android thread priority constants to be consistent with the rest
3083  
- * of the system.  In some cases adjacent entries may overlap.
3084  
- */
3085  
-static const int kNiceValues[10] = {
3086  
-    ANDROID_PRIORITY_LOWEST,                /* 1 (MIN_PRIORITY) */
3087  
-    ANDROID_PRIORITY_BACKGROUND + 6,
3088  
-    ANDROID_PRIORITY_BACKGROUND + 3,
3089  
-    ANDROID_PRIORITY_BACKGROUND,
3090  
-    ANDROID_PRIORITY_NORMAL,                /* 5 (NORM_PRIORITY) */
3091  
-    ANDROID_PRIORITY_NORMAL - 2,
3092  
-    ANDROID_PRIORITY_NORMAL - 4,
3093  
-    ANDROID_PRIORITY_URGENT_DISPLAY + 3,
3094  
-    ANDROID_PRIORITY_URGENT_DISPLAY + 2,
3095  
-    ANDROID_PRIORITY_URGENT_DISPLAY         /* 10 (MAX_PRIORITY) */
3096  
-};
3097  
-
3098  
-/*
3099  
- * Change the priority of a system thread to match that of the Thread object.
3100  
- *
3101  
- * We map a priority value from 1-10 to Linux "nice" values, where lower
3102  
- * numbers indicate higher priority.
3103  
- */
3104 3076
 void dvmChangeThreadPriority(Thread* thread, int newPriority)
3105 3077
 {
3106  
-    pid_t pid = thread->systemTid;
3107  
-    int newNice;
3108  
-
3109  
-    if (newPriority < 1 || newPriority > 10) {
3110  
-        LOGW("bad priority %d", newPriority);
3111  
-        newPriority = 5;
3112  
-    }
3113  
-    newNice = kNiceValues[newPriority-1];
3114  
-
3115  
-    if (newNice >= ANDROID_PRIORITY_BACKGROUND) {
3116  
-        set_sched_policy(dvmGetSysThreadId(), SP_BACKGROUND);
3117  
-    } else if (getpriority(PRIO_PROCESS, pid) >= ANDROID_PRIORITY_BACKGROUND) {
3118  
-        set_sched_policy(dvmGetSysThreadId(), SP_FOREGROUND);
3119  
-    }
3120  
-
3121  
-    if (setpriority(PRIO_PROCESS, pid, newNice) != 0) {
3122  
-        std::string threadName(dvmGetThreadName(thread));
3123  
-        LOGI("setPriority(%d) '%s' to prio=%d(n=%d) failed: %s",
3124  
-                pid, threadName.c_str(), newPriority, newNice, strerror(errno));
3125  
-    } else {
3126  
-        LOGV("setPriority(%d) to prio=%d(n=%d)", pid, newPriority, newNice);
3127  
-    }
  3078
+    os_changeThreadPriority(thread, newPriority);
3128 3079
 }
3129 3080
 
3130 3081
 /*
3131  
- * Get the thread priority for the current thread by querying the system.
3132  
- * This is useful when attaching a thread through JNI.
3133  
- *
3134  
- * Returns a value from 1 to 10 (compatible with java.lang.Thread values).
3135  
- */
3136  
-static int getThreadPriorityFromSystem()
3137  
-{
3138  
-    int i, sysprio, jprio;
3139  
-
3140  
-    errno = 0;
3141  
-    sysprio = getpriority(PRIO_PROCESS, 0);
3142  
-    if (sysprio == -1 && errno != 0) {
3143  
-        LOGW("getpriority() failed: %s", strerror(errno));
3144  
-        return THREAD_NORM_PRIORITY;
3145  
-    }
3146  
-
3147  
-    jprio = THREAD_MIN_PRIORITY;
3148  
-    for (i = 0; i < NELEM(kNiceValues); i++) {
3149  
-        if (sysprio >= kNiceValues[i])
3150  
-            break;
3151  
-        jprio++;
3152  
-    }
3153  
-    if (jprio > THREAD_MAX_PRIORITY)
3154  
-        jprio = THREAD_MAX_PRIORITY;
3155  
-
3156  
-    return jprio;
3157  
-}
3158  
-
3159  
-
3160  
-/*
3161 3082
  * Return true if the thread is on gDvm.threadList.
3162 3083
  * Caller should not hold gDvm.threadListLock.
3163 3084
  */
63  vm/alloc/Heap.cpp
@@ -24,10 +24,7 @@
24 24
 #include "alloc/DdmHeap.h"
25 25
 #include "alloc/HeapSource.h"
26 26
 #include "alloc/MarkSweep.h"
27  
-
28  
-#include "utils/threads.h"      // need Android thread priorities
29  
-
30  
-#include <cutils/sched_policy.h>
  27
+#include "os/os.h"
31 28
 
32 29
 #include <sys/time.h>
33 30
 #include <sys/resource.h>
@@ -443,60 +440,6 @@ static void verifyRootsAndHeap()
443 440
 }
444 441
 
445 442
 /*
446  
- * Raises the scheduling priority of the current thread.  Returns the
447  
- * original priority if successful.  Otherwise, returns INT_MAX on
448  
- * failure.
449  
- */
450  
-static int raiseThreadPriority()
451  
-{
452  
-    /* Get the priority (the "nice" value) of the current thread.  The
453  
-     * getpriority() call can legitimately return -1, so we have to
454  
-     * explicitly test errno.
455  
-     */
456  
-    errno = 0;
457  
-    int oldThreadPriority = getpriority(PRIO_PROCESS, 0);
458  
-    if (errno != 0) {
459  
-        LOGI_HEAP("getpriority(self) failed: %s", strerror(errno));
460  
-    } else if (oldThreadPriority > ANDROID_PRIORITY_NORMAL) {
461  
-        /* Current value is numerically greater than "normal", which
462  
-         * in backward UNIX terms means lower priority.
463  
-         */
464  
-        if (oldThreadPriority >= ANDROID_PRIORITY_BACKGROUND) {
465  
-            set_sched_policy(dvmGetSysThreadId(), SP_FOREGROUND);
466  
-        }
467  
-        if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_NORMAL) != 0) {
468  
-            LOGI_HEAP("Unable to elevate priority from %d to %d",
469  
-                      oldThreadPriority, ANDROID_PRIORITY_NORMAL);
470  
-        } else {
471  
-            /*
472  
-             * The priority has been elevated.  Return the old value
473  
-             * so the caller can restore it later.
474  
-             */
475  
-            LOGD_HEAP("Elevating priority from %d to %d",
476  
-                      oldThreadPriority, ANDROID_PRIORITY_NORMAL);
477  
-            return oldThreadPriority;
478  
-        }
479  
-    }
480  
-    return INT_MAX;
481  
-}
482  
-
483  
-/*
484  
- * Sets the current thread scheduling priority.
485  
- */
486  
-static void setThreadPriority(int newThreadPriority)
487  
-{
488  
-    if (setpriority(PRIO_PROCESS, 0, newThreadPriority) != 0) {
489  
-        LOGW_HEAP("Unable to reset priority to %d: %s",
490  
-                  newThreadPriority, strerror(errno));
491  
-    } else {
492  
-        LOGD_HEAP("Reset priority to %d", oldThreadPriority);
493  
-    }
494  
-    if (newThreadPriority >= ANDROID_PRIORITY_BACKGROUND) {
495  
-        set_sched_policy(dvmGetSysThreadId(), SP_BACKGROUND);
496  
-    }
497  
-}
498  
-
499  
-/*
500 443
  * Initiate garbage collection.
501 444
  *
502 445
  * NOTES:
@@ -541,7 +484,7 @@ void dvmCollectGarbageInternal(const GcSpec* spec)
541 484
      * thread performing the garbage collection.
542 485
      */
543 486
     if (!spec->isConcurrent) {
544  
-        oldThreadPriority = raiseThreadPriority();
  487
+        oldThreadPriority = os_raiseThreadPriority();
545 488
     }
546 489
     if (gDvm.preVerify) {
547 490
         LOGV_HEAP("Verifying roots and heap before GC");
@@ -704,7 +647,7 @@ void dvmCollectGarbageInternal(const GcSpec* spec)
704 647
          * changed at the start of the current garbage collection.
705 648
          */
706 649
         if (oldThreadPriority != INT_MAX) {
707  
-            setThreadPriority(oldThreadPriority);
  650
+            os_lowerThreadPriority(oldThreadPriority);
708 651
         }
709 652
     }
710 653
 
139  vm/os/android.cpp
... ...
@@ -0,0 +1,139 @@
  1
+/*
  2
+ * Copyright (C) 2011 The Android Open Source Project
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+#include "os.h"
  18
+
  19
+#include "Dalvik.h"
  20
+
  21
+#include <sys/time.h>
  22
+#include <sys/resource.h>
  23
+#include <limits.h>
  24
+#include <errno.h>
  25
+
  26
+#include <cutils/sched_policy.h>
  27
+#include <utils/threads.h>
  28
+
  29
+/*
  30
+ * Conversion map for "nice" values.
  31
+ *
  32
+ * We use Android thread priority constants to be consistent with the rest
  33
+ * of the system.  In some cases adjacent entries may overlap.
  34
+ */
  35
+static const int kNiceValues[10] = {
  36
+    ANDROID_PRIORITY_LOWEST,                /* 1 (MIN_PRIORITY) */
  37
+    ANDROID_PRIORITY_BACKGROUND + 6,
  38
+    ANDROID_PRIORITY_BACKGROUND + 3,
  39
+    ANDROID_PRIORITY_BACKGROUND,
  40
+    ANDROID_PRIORITY_NORMAL,                /* 5 (NORM_PRIORITY) */
  41
+    ANDROID_PRIORITY_NORMAL - 2,
  42
+    ANDROID_PRIORITY_NORMAL - 4,
  43
+    ANDROID_PRIORITY_URGENT_DISPLAY + 3,
  44
+    ANDROID_PRIORITY_URGENT_DISPLAY + 2,
  45
+    ANDROID_PRIORITY_URGENT_DISPLAY         /* 10 (MAX_PRIORITY) */
  46
+};
  47
+
  48
+void os_changeThreadPriority(Thread* thread, int newPriority)
  49
+{
  50
+    if (newPriority < 1 || newPriority > 10) {
  51
+        LOGW("bad priority %d", newPriority);
  52
+        newPriority = 5;
  53
+    }
  54
+
  55
+    int newNice = kNiceValues[newPriority-1];
  56
+    pid_t pid = thread->systemTid;
  57
+
  58
+    if (newNice >= ANDROID_PRIORITY_BACKGROUND) {
  59
+        set_sched_policy(dvmGetSysThreadId(), SP_BACKGROUND);
  60
+    } else if (getpriority(PRIO_PROCESS, pid) >= ANDROID_PRIORITY_BACKGROUND) {
  61
+        set_sched_policy(dvmGetSysThreadId(), SP_FOREGROUND);
  62
+    }
  63
+
  64
+    if (setpriority(PRIO_PROCESS, pid, newNice) != 0) {
  65
+        std::string threadName(dvmGetThreadName(thread));
  66
+        LOGI("setPriority(%d) '%s' to prio=%d(n=%d) failed: %s",
  67
+        pid, threadName.c_str(), newPriority, newNice, strerror(errno));
  68
+    } else {
  69
+        LOGV("setPriority(%d) to prio=%d(n=%d)", pid, newPriority, newNice);
  70
+    }
  71
+}
  72
+
  73
+int os_getThreadPriorityFromSystem()
  74
+{
  75
+    errno = 0;
  76
+    int sysprio = getpriority(PRIO_PROCESS, 0);
  77
+    if (sysprio == -1 && errno != 0) {
  78
+        LOGW("getpriority() failed: %s", strerror(errno));
  79
+        return THREAD_NORM_PRIORITY;
  80
+    }
  81
+
  82
+    int jprio = THREAD_MIN_PRIORITY;
  83
+    for (int i = 0; i < NELEM(kNiceValues); i++) {
  84
+        if (sysprio >= kNiceValues[i]) {
  85
+            break;
  86
+        }
  87
+        jprio++;
  88
+    }
  89
+    if (jprio > THREAD_MAX_PRIORITY) {
  90
+        jprio = THREAD_MAX_PRIORITY;
  91
+    }
  92
+    return jprio;
  93
+}
  94
+
  95
+int os_raiseThreadPriority()
  96
+{
  97
+    /* Get the priority (the "nice" value) of the current thread.  The
  98
+     * getpriority() call can legitimately return -1, so we have to
  99
+     * explicitly test errno.
  100
+     */
  101
+    errno = 0;
  102
+    int oldThreadPriority = getpriority(PRIO_PROCESS, 0);
  103
+    if (errno != 0) {
  104
+        LOGI("getpriority(self) failed: %s", strerror(errno));
  105
+    } else if (oldThreadPriority > ANDROID_PRIORITY_NORMAL) {
  106
+        /* Current value is numerically greater than "normal", which
  107
+         * in backward UNIX terms means lower priority.
  108
+         */
  109
+        if (oldThreadPriority >= ANDROID_PRIORITY_BACKGROUND) {
  110
+            set_sched_policy(dvmGetSysThreadId(), SP_FOREGROUND);
  111
+        }
  112
+        if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_NORMAL) != 0) {
  113
+            LOGI("Unable to elevate priority from %d to %d",
  114
+                    oldThreadPriority, ANDROID_PRIORITY_NORMAL);
  115
+        } else {
  116
+            /*
  117
+             * The priority has been elevated.  Return the old value
  118
+             * so the caller can restore it later.
  119
+             */
  120
+            LOGD("Elevating priority from %d to %d",
  121
+                    oldThreadPriority, ANDROID_PRIORITY_NORMAL);
  122
+            return oldThreadPriority;
  123
+        }
  124
+    }
  125
+    return INT_MAX;
  126
+}
  127
+
  128
+void os_lowerThreadPriority(int oldThreadPriority)
  129
+{
  130
+    if (setpriority(PRIO_PROCESS, 0, oldThreadPriority) != 0) {
  131
+        LOGW("Unable to reset priority to %d: %s",
  132
+                oldThreadPriority, strerror(errno));
  133
+    } else {
  134
+        LOGD("Reset priority to %d", oldThreadPriority);
  135
+    }
  136
+    if (oldThreadPriority >= ANDROID_PRIORITY_BACKGROUND) {
  137
+        set_sched_policy(dvmGetSysThreadId(), SP_BACKGROUND);
  138
+    }
  139
+}
39  vm/os/linux.cpp
... ...
@@ -0,0 +1,39 @@
  1
+/*
  2
+ * Copyright (C) 2011 The Android Open Source Project
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+#include "os.h"
  18
+
  19
+#include "Dalvik.h"
  20
+
  21
+int os_raiseThreadPriority()
  22
+{
  23
+    return 0;
  24
+}
  25
+
  26
+void os_lowerThreadPriority(int oldThreadPriority)
  27
+{
  28
+    // Do nothing.
  29
+}
  30
+
  31
+void os_changeThreadPriority(Thread* thread, int newPriority)
  32
+{
  33
+    // Do nothing.
  34
+}
  35
+
  36
+int os_getThreadPriorityFromSystem()
  37
+{
  38
+    return THREAD_NORM_PRIORITY;
  39
+}
50  vm/os/os.h
... ...
@@ -0,0 +1,50 @@
  1
+/*
  2
+ * Copyright (C) 2011 The Android Open Source Project
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+struct Thread;
  18
+
  19
+/*
  20
+ * Raises the scheduling priority of the current thread.  Returns the
  21
+ * original priority if successful, or INT_MAX on failure.
  22
+ * Use os_lowerThreadPriority to undo.
  23
+ *
  24
+ * TODO: does the GC really need this?
  25
+ */
  26
+int os_raiseThreadPriority();
  27
+
  28
+/*
  29
+ * Sets the current thread scheduling priority. Used to undo the effects
  30
+ * of an earlier call to os_raiseThreadPriority.
  31
+ *
  32
+ * TODO: does the GC really need this?
  33
+ */
  34
+void os_lowerThreadPriority(int oldThreadPriority);
  35
+
  36
+/*
  37
+ * Changes the priority of a system thread to match that of the Thread object.
  38
+ *
  39
+ * We map a priority value from 1-10 to Linux "nice" values, where lower
  40
+ * numbers indicate higher priority.
  41
+ */
  42
+void os_changeThreadPriority(Thread* thread, int newPriority);
  43
+
  44
+/*
  45
+ * Returns the thread priority for the current thread by querying the system.
  46
+ * This is useful when attaching a thread through JNI.
  47
+ *
  48
+ * Returns a value from 1 to 10 (compatible with java.lang.Thread values).
  49
+ */
  50
+int os_getThreadPriorityFromSystem();

0 notes on commit e6c0ef2

Please sign in to comment.
Something went wrong with that request. Please try again.