diff options
author | Keith Packard <keithp@keithp.com> | 2016-05-19 15:05:55 -0700 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2016-07-18 15:27:51 -0400 |
commit | 7762a602c1dfdd8cfcf2b8c2281cf4d683d05216 (patch) | |
tree | fcf8b465241641e5c42ad90cc1f98842e8c39af6 /dix | |
parent | 4af00242ef1e39499b932d12423fdf449296090a (diff) |
dix/os: Merge priority computation into SmartScheduleClient
Instead of having scheduling done in two places (one in
WaitForSomething, and the other in SmartScheduleClient), just stick
all of the scheduling in SmartScheduleClient.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/dispatch.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/dix/dispatch.c b/dix/dispatch.c index a4e535834..28a3c3f5f 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -244,15 +244,13 @@ void Dispatch(void); static int SmartScheduleClient(int *clientReady, int nready) { - ClientPtr pClient; int i; int client; - int bestPrio, best = 0; + ClientPtr pClient, best = NULL; int bestRobin, robin; long now = SmartScheduleTime; long idle; - bestPrio = -0x7fffffff; bestRobin = 0; idle = 2 * SmartScheduleSlice; for (i = 0; i < nready; i++) { @@ -269,11 +267,16 @@ SmartScheduleClient(int *clientReady, int nready) (pClient->index - SmartLastIndex[pClient->smart_priority - SMART_MIN_PRIORITY]) & 0xff; - if (pClient->smart_priority > bestPrio || - (pClient->smart_priority == bestPrio && robin > bestRobin)) { - bestPrio = pClient->smart_priority; + + /* pick the best client */ + if (!best || + pClient->priority > best->priority || + (pClient->priority == best->priority && + (pClient->smart_priority > best->smart_priority || + (pClient->smart_priority == best->smart_priority && robin > bestRobin)))) + { + best = pClient; bestRobin = robin; - best = client; } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) @@ -286,8 +289,7 @@ SmartScheduleClient(int *clientReady, int nready) SmartLastPrint = now; } #endif - pClient = clients[best]; - SmartLastIndex[bestPrio - SMART_MIN_PRIORITY] = pClient->index; + SmartLastIndex[best->smart_priority - SMART_MIN_PRIORITY] = best->index; /* * Set current client pointer */ @@ -312,7 +314,7 @@ SmartScheduleClient(int *clientReady, int nready) else { SmartScheduleSlice = SmartScheduleInterval; } - return best; + return best->index; } void |