aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-02-16 15:04:43 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-03-21 10:33:30 +0100
commitf14f738a627b5a6f6c1242f4fe123e4cc9e9c811 (patch)
treef5e76985e4a9701124e021dc4168c0777b6ed11d /nx-X11/programs
parent6c076cfe5a656b03d4bd0dd9742e7a02dce2b957 (diff)
downloadnx-libs-f14f738a627b5a6f6c1242f4fe123e4cc9e9c811.tar.gz
nx-libs-f14f738a627b5a6f6c1242f4fe123e4cc9e9c811.tar.bz2
nx-libs-f14f738a627b5a6f6c1242f4fe123e4cc9e9c811.zip
dix/os: Merge priority computation into SmartScheduleClient
Backported from X.org: commit 7762a602c1dfdd8cfcf2b8c2281cf4d683d05216 Author: Keith Packard <keithp@keithp.com> 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 <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Backported-to-NX-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'nx-X11/programs')
-rw-r--r--nx-X11/programs/Xserver/dix/dispatch.c25
-rw-r--r--nx-X11/programs/Xserver/os/WaitFor.c41
2 files changed, 18 insertions, 48 deletions
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
diff --git a/nx-X11/programs/Xserver/os/WaitFor.c b/nx-X11/programs/Xserver/os/WaitFor.c
index 3ac2e1c7e..02c460f0c 100644
--- a/nx-X11/programs/Xserver/os/WaitFor.c
+++ b/nx-X11/programs/Xserver/os/WaitFor.c
@@ -544,17 +544,14 @@ WaitForSomething(int *pClientsReady)
#ifndef WIN32
for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
{
- int highest_priority = 0;
-
while (clientsReadable.fds_bits[i])
{
- int client_priority, client_index;
+ int client_index;
curclient = ffs (clientsReadable.fds_bits[i]) - 1;
client_index = /* raphael: modified */
ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
#else
- int highest_priority = 0;
fd_set savedClientsReadable;
XFD_COPYSET(&clientsReadable, &savedClientsReadable);
for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++)
@@ -564,40 +561,10 @@ WaitForSomething(int *pClientsReady)
curclient = XFD_FD(&savedClientsReadable, i);
client_index = GetConnectionTranslation(curclient);
#endif
-#ifdef XSYNC
- /* We implement "strict" priorities.
- * Only the highest priority client is returned to
- * dix. If multiple clients at the same priority are
- * ready, they are all returned. This means that an
- * aggressive client could take over the server.
- * This was not considered a big problem because
- * aggressive clients can hose the server in so many
- * other ways :)
- */
- client_priority = clients[client_index]->priority;
- if (nready == 0 || client_priority > highest_priority)
- {
- /* Either we found the first client, or we found
- * a client whose priority is greater than all others
- * that have been found so far. Either way, we want
- * to initialize the list of clients to contain just
- * this client.
- */
- pClientsReady[0] = client_index;
- highest_priority = client_priority;
- nready = 1;
- }
- /* the following if makes sure that multiple same-priority
- * clients get batched together
- */
- else if (client_priority == highest_priority)
-#endif
- {
- pClientsReady[nready++] = client_index;
- }
+ pClientsReady[nready++] = client_index;
#ifndef WIN32
- clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
- }
+ clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
+ }
#else
FD_CLR(curclient, &clientsReadable);
#endif