Merge "Implements layoutTestController.setAppCacheMaximumSize"
diff --git a/include/utils/threads.h b/include/utils/threads.h
index 130d83c..5ac0c5e 100644
--- a/include/utils/threads.h
+++ b/include/utils/threads.h
@@ -209,7 +209,7 @@
class Mutex {
public:
enum {
- NORMAL = 0,
+ PRIVATE = 0,
SHARED = 1
};
@@ -305,7 +305,13 @@
*/
class Condition {
public:
+ enum {
+ PRIVATE = 0,
+ SHARED = 1
+ };
+
Condition();
+ Condition(int type);
~Condition();
// Wait on the condition variable. Lock the mutex before calling.
status_t wait(Mutex& mutex);
@@ -329,6 +335,17 @@
inline Condition::Condition() {
pthread_cond_init(&mCond, NULL);
}
+inline Condition::Condition(int type) {
+ if (type == SHARED) {
+ pthread_condattr_t attr;
+ pthread_condattr_init(&attr);
+ pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ pthread_cond_init(&mCond, &attr);
+ pthread_condattr_destroy(&attr);
+ } else {
+ pthread_cond_init(&mCond, NULL);
+ }
+}
inline Condition::~Condition() {
pthread_cond_destroy(&mCond);
}
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 473f580..0016503 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -935,17 +935,27 @@
mCallingPid = tr.sender_pid;
mCallingUid = tr.sender_euid;
- bool doBackground = !gDisableBackgroundScheduling &&
- getpriority(PRIO_PROCESS, mMyThreadId)
- >= ANDROID_PRIORITY_BACKGROUND;
- if (doBackground) {
- // We have inherited a background priority from the caller.
- // Ensure this thread is in the background scheduling class,
- // since the driver won't modify scheduling classes for us.
- androidSetThreadSchedulingGroup(mMyThreadId,
- ANDROID_TGROUP_BG_NONINTERACT);
+ int curPrio = getpriority(PRIO_PROCESS, mMyThreadId);
+ if (gDisableBackgroundScheduling) {
+ if (curPrio > ANDROID_PRIORITY_NORMAL) {
+ // We have inherited a reduced priority from the caller, but do not
+ // want to run in that state in this process. The driver set our
+ // priority already (though not our scheduling class), so bounce
+ // it back to the default before invoking the transaction.
+ setpriority(PRIO_PROCESS, mMyThreadId, ANDROID_PRIORITY_NORMAL);
+ }
+ } else {
+ if (curPrio >= ANDROID_PRIORITY_BACKGROUND) {
+ // We want to use the inherited priority from the caller.
+ // Ensure this thread is in the background scheduling class,
+ // since the driver won't modify scheduling classes for us.
+ // The scheduling group is reset to default by the caller
+ // once this method returns after the transaction is complete.
+ androidSetThreadSchedulingGroup(mMyThreadId,
+ ANDROID_TGROUP_BG_NONINTERACT);
+ }
}
-
+
//LOGI(">>>> TRANSACT from pid %d uid %d\n", mCallingPid, mCallingUid);
Parcel reply;
@@ -982,14 +992,7 @@
mCallingPid = origPid;
mCallingUid = origUid;
-
- if (doBackground) {
- // We moved to the background scheduling group to execute
- // this transaction, so now that we are done go back in the
- // foreground.
- androidSetThreadSchedulingGroup(mMyThreadId, ANDROID_TGROUP_DEFAULT);
- }
-
+
IF_LOG_TRANSACTIONS() {
TextOutput::Bundle _b(alog);
alog << "BC_REPLY thr " << (void*)pthread_self() << " / obj "
diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp
index 65ce1c1..a17e8ac 100644
--- a/libs/surfaceflinger_client/SharedBufferStack.cpp
+++ b/libs/surfaceflinger_client/SharedBufferStack.cpp
@@ -34,7 +34,7 @@
// ----------------------------------------------------------------------------
SharedClient::SharedClient()
- : lock(Mutex::SHARED)
+ : lock(Mutex::SHARED), cv(Condition::SHARED)
{
}