client: fix bugs involving CPU throttling and GPU apps

Suspended tasks can be either left in memory (LIM) or removed
from memory (RFM).
CPU throttling always uses LIM.
Other types of suspension (e.g. user request) use LIM or RFM
depending on user prefs, except that RFM is always used for GPU tasks.

There was a bug: if tasks were suspended because of CPU throttling,
and then the user suspended activity,
GPU apps would remain LIM.
They need to be RFM.
This commit is contained in:
David Anderson 2013-12-12 00:03:22 -08:00
parent f2183fe8e3
commit 47b4d6bacc
3 changed files with 3 additions and 5 deletions

View File

@ -184,6 +184,7 @@ int ACTIVE_TASK::preempt(int preempt_type) {
result->name result->name
); );
} }
if (task_state() != PROCESS_EXECUTING) return 0;
return suspend(); return suspend();
} }
return 0; return 0;

View File

@ -1055,14 +1055,13 @@ int ACTIVE_TASK_SET::abort_project(PROJECT* project) {
void ACTIVE_TASK_SET::suspend_all(int reason) { void ACTIVE_TASK_SET::suspend_all(int reason) {
for (unsigned int i=0; i<active_tasks.size(); i++) { for (unsigned int i=0; i<active_tasks.size(); i++) {
ACTIVE_TASK* atp = active_tasks[i]; ACTIVE_TASK* atp = active_tasks[i];
if (atp->task_state() != PROCESS_EXECUTING) continue;
// handle CPU throttling separately // handle CPU throttling separately
// //
if (reason == SUSPEND_REASON_CPU_THROTTLE) { if (reason == SUSPEND_REASON_CPU_THROTTLE) {
if (atp->result->dont_throttle()) continue; if (atp->result->dont_throttle()) continue;
atp->preempt(REMOVE_NEVER); atp->preempt(REMOVE_NEVER);
continue;; continue;
} }
#ifdef ANDROID #ifdef ANDROID

View File

@ -864,9 +864,7 @@ bool CLIENT_STATE::poll_slow_events() {
if (suspend_reason) { if (suspend_reason) {
if (!tasks_suspended) { if (!tasks_suspended) {
show_suspend_tasks_message(suspend_reason); show_suspend_tasks_message(suspend_reason);
if (!tasks_throttled) { active_tasks.suspend_all(suspend_reason);
active_tasks.suspend_all(suspend_reason);
}
} }
last_suspend_reason = suspend_reason; last_suspend_reason = suspend_reason;
} else { } else {