From f14f738a627b5a6f6c1242f4fe123e4cc9e9c811 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 16 Feb 2017 15:04:43 +0000 Subject: dix/os: Merge priority computation into SmartScheduleClient Backported from X.org: commit 7762a602c1dfdd8cfcf2b8c2281cf4d683d05216 Author: Keith Packard Date: Thu May 19 15:05:55 2016 -0700 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 Reviewed-by: Adam Jackson Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/dix/dispatch.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'nx-X11/programs/Xserver/dix') diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 7b2aa7b3d..68c207e33 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -240,15 +240,13 @@ void InitProcVectors(void); 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++) @@ -264,13 +262,19 @@ SmartScheduleClient (int *clientReady, int nready) pClient->smart_check_tick = now; /* check priority to select best client */ - robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff; - if (pClient->smart_priority > bestPrio || - (pClient->smart_priority == bestPrio && robin > bestRobin)) + robin = (pClient->index - + SmartLastIndex[pClient->smart_priority - + SMART_MIN_PRIORITY]) & 0xff; + + /* 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)))) { - bestPrio = pClient->smart_priority; + best = pClient; bestRobin = robin; - best = client; } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) @@ -284,8 +288,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 */ @@ -314,7 +317,7 @@ SmartScheduleClient (int *clientReady, int nready) { SmartScheduleSlice = SmartScheduleInterval; } - return best; + return best->index; } #ifndef NXAGENT_SERVER -- cgit v1.2.3