This allows the server to call GetTimeInMillis() after each request is processed to avoid needing setitimer. -dumbSched now turns off the setitimer.
Signed-off-by: Keith Packard <[email protected]> --- configure.ac | 2 +- dix/dispatch.c | 17 +++++++++++------ include/dix-config.h.in | 3 +++ include/dixstruct.h | 4 +++- os/WaitFor.c | 14 ++++---------- os/io.c | 13 ++----------- os/utils.c | 23 ++++++++++++----------- 7 files changed, 36 insertions(+), 40 deletions(-) diff --git a/configure.ac b/configure.ac index 8d6a950..ec6b1a7 100644 --- a/configure.ac +++ b/configure.ac @@ -218,7 +218,7 @@ AC_SUBST(DLOPEN_LIBS) dnl Checks for library functions. AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \ getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \ - mmap seteuid shmctl64 strncasecmp vasprintf vsnprintf walkcontext]) + mmap seteuid shmctl64 strncasecmp vasprintf vsnprintf walkcontext setitimer]) AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup]) AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]]) diff --git a/dix/dispatch.c b/dix/dispatch.c index 2c20124..aa4ec7c 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -222,11 +222,13 @@ UpdateCurrentTimeIf(void) #define SMART_SCHEDULE_DEFAULT_INTERVAL 5 #define SMART_SCHEDULE_MAX_SLICE 15 -#if defined(WIN32) && !defined(__CYGWIN__) -Bool SmartScheduleDisable = TRUE; +#ifdef HAVE_SETITIMER +#define SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE HAVE_SETITIMER #else -Bool SmartScheduleDisable = FALSE; +#define SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE FALSE #endif + +Bool SmartScheduleSignalEnable = SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE; long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; @@ -358,7 +360,7 @@ Dispatch(void) nready = WaitForSomething(clientReady); - if (nready && !SmartScheduleDisable) { + if (nready) { clientReady[0] = SmartScheduleClient(clientReady, nready); nready = 1; } @@ -386,8 +388,8 @@ Dispatch(void) ProcessInputEvents(); FlushIfCriticalOutputPending(); - if (!SmartScheduleDisable && - (SmartScheduleTime - start_tick) >= SmartScheduleSlice) { + if ((SmartScheduleTime - start_tick) >= SmartScheduleSlice) + { /* Penalize clients which consume ticks */ if (client->smart_priority > SMART_MIN_PRIORITY) client->smart_priority--; @@ -431,6 +433,9 @@ Dispatch(void) (*client->requestVector[client->majorOp]) (client); XaceHookAuditEnd(client, result); } + if (!SmartScheduleSignalEnable) + SmartScheduleTime = GetTimeInMillis(); + #ifdef XSERVER_DTRACE if (XSERVER_REQUEST_DONE_ENABLED()) XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp), diff --git a/include/dix-config.h.in b/include/dix-config.h.in index c2ba434..c0cb25a 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -518,4 +518,7 @@ /* Listen on local socket */ #undef LISTEN_LOCAL +/* Have setitimer support */ +#undef HAVE_SETITIMER + #endif /* _DIX_CONFIG_H_ */ diff --git a/include/dixstruct.h b/include/dixstruct.h index 7575066..1bf1949 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -130,9 +130,11 @@ extern long SmartScheduleTime; extern long SmartScheduleInterval; extern long SmartScheduleSlice; extern long SmartScheduleMaxSlice; -extern Bool SmartScheduleDisable; +extern Bool SmartScheduleSignalEnable; +#if HAVE_SETITIMER extern void SmartScheduleStartTimer(void); extern void SmartScheduleStopTimer(void); +#endif #define SMART_MAX_PRIORITY (20) #define SMART_MIN_PRIORITY (-20) diff --git a/os/WaitFor.c b/os/WaitFor.c index 431f1a6..424cdfc 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -174,16 +174,10 @@ WaitForSomething(int *pClientsReady) if (workQueue) ProcessWorkQueue(); if (XFD_ANYSET(&ClientsWithInput)) { - if (!SmartScheduleDisable) { - someReady = TRUE; - waittime.tv_sec = 0; - waittime.tv_usec = 0; - wt = &waittime; - } - else { - XFD_COPYSET(&ClientsWithInput, &clientsReadable); - break; - } + someReady = TRUE; + waittime.tv_sec = 0; + waittime.tv_usec = 0; + wt = &waittime; } if (someReady) { XFD_COPYSET(&AllSockets, &LastSelectMask); diff --git a/os/io.c b/os/io.c index 96a243d..864f44a 100644 --- a/os/io.c +++ b/os/io.c @@ -462,23 +462,14 @@ ReadRequestFromClient(ClientPtr client) ) FD_SET(fd, &ClientsWithInput); else { - if (!SmartScheduleDisable) - FD_CLR(fd, &ClientsWithInput); - else - YieldControlNoInput(fd); + FD_CLR(fd, &ClientsWithInput); } } else { if (!gotnow) AvailableInput = oc; - if (!SmartScheduleDisable) - FD_CLR(fd, &ClientsWithInput); - else - YieldControlNoInput(fd); + FD_CLR(fd, &ClientsWithInput); } - if (SmartScheduleDisable) - if (++timesThisConnection >= MAX_TIMES_PER) - YieldControl(); if (move_header) { request = (xReq *) oci->bufptr; oci->bufptr += (sizeof(xBigReq) - sizeof(xReq)); diff --git a/os/utils.c b/os/utils.c index 868eb04..c23c0d1 100644 --- a/os/utils.c +++ b/os/utils.c @@ -71,7 +71,6 @@ __stdcall unsigned long GetTickCount(void); #if !defined(WIN32) || !defined(__MINGW32__) #include <sys/time.h> #include <sys/resource.h> -# define SMART_SCHEDULE_POSSIBLE #endif #include "misc.h" #include <X11/X.h> @@ -1005,10 +1004,11 @@ ProcessCommandLine(int argc, char *argv[]) i = skip - 1; } #endif -#ifdef SMART_SCHEDULE_POSSIBLE +#if HAVE_SETITIMER else if (strcmp(argv[i], "-dumbSched") == 0) { - SmartScheduleDisable = TRUE; + SmartScheduleSignalEnable = FALSE; } +#endif else if (strcmp(argv[i], "-schedInterval") == 0) { if (++i < argc) { SmartScheduleInterval = atoi(argv[i]); @@ -1024,7 +1024,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } -#endif else if (strcmp(argv[i], "-render") == 0) { if (++i < argc) { int policy = PictureParseCmapPolicy(argv[i]); @@ -1208,10 +1207,10 @@ XNFstrdup(const char *s) void SmartScheduleStopTimer(void) { -#ifdef SMART_SCHEDULE_POSSIBLE +#if HAVE_SETITIMER struct itimerval timer; - if (SmartScheduleDisable) + if (!SmartScheduleSignalEnable) return; timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; @@ -1224,10 +1223,10 @@ SmartScheduleStopTimer(void) void SmartScheduleStartTimer(void) { -#ifdef SMART_SCHEDULE_POSSIBLE +#if HAVE_SETITIMER struct itimerval timer; - if (SmartScheduleDisable) + if (!SmartScheduleSignalEnable) return; timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = SmartScheduleInterval * 1000; @@ -1237,19 +1236,21 @@ SmartScheduleStartTimer(void) #endif } +#if HAVE_SETITIMER static void SmartScheduleTimer(int sig) { SmartScheduleTime += SmartScheduleInterval; } +#endif void SmartScheduleInit(void) { -#ifdef SMART_SCHEDULE_POSSIBLE +#if HAVE_SETITIMER struct sigaction act; - if (SmartScheduleDisable) + if (!SmartScheduleSignalEnable) return; memset((char *) &act, 0, sizeof(struct sigaction)); @@ -1260,7 +1261,7 @@ SmartScheduleInit(void) sigaddset(&act.sa_mask, SIGALRM); if (sigaction(SIGALRM, &act, 0) < 0) { perror("sigaction for smart scheduler"); - SmartScheduleDisable = TRUE; + SmartScheduleSignalEnable = FALSE; } #endif } -- 2.5.0 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
