[ActivityManager] Fix race condition in pss collection

Symptom:
There has a race condition that two threads are accessing
the mPendingPssProcesses simultaneously. One of the thread
is collecting the process pss by looping the mPendingPssProcesses.
The other thread is requesting to collect pss of all processes,
which clears mPendingPssProcesses and adding processes back.

Solution:
Avoid race condition by adding synchornized protection.

Change-Id: Ifb090eda9c4a1b8e3fd980fe0171e9dd77773b46
This commit is contained in:
louis_chang
2014-12-02 12:57:39 +08:00
committed by Craig Mautner
parent 932c332147
commit 71e737c8e8

View File

@@ -1669,7 +1669,9 @@ public final class ActivityManagerService extends ActivityManagerNative
break;
}
case REQUEST_ALL_PSS_MSG: {
requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
synchronized (ActivityManagerService.this) {
requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
}
break;
}
case START_PROFILES_MSG: {