# dmxsync.c File Reference

`#include "dmx.h"`
`#include "dmxsync.h"`
`#include "dmxstat.h"`
`#include "dmxlog.h"`
`#include <sys/time.h>`

## Functions

static void | dmxDoSync (DMXScreenInfo *dmxScreen)
static CARD32 | dmxSyncCallback (OsTimerPtr timer, CARD32 time, pointer arg)
static void | dmxSyncBlockHandler (pointer blockData, OSTimePtr pTimeout, pointer pReadMask)
static void | dmxSyncWakeupHandler (pointer blockData, int result, pointer pReadMask)
void | dmxSyncActivate (const char *interval)
void | dmxSyncInit (void)
void | dmxSync (DMXScreenInfo *dmxScreen, Bool now)

## Variables

static int | dmxSyncInterval = 100
static OsTimerPtr | dmxSyncTimer
static int | dmxSyncPending

## Detailed Description

The DMX server code is written to call dmxSync() whenever an XSync() might be necessary. However, since XSync() requires a two way communication with the other X server, eliminating unnecessary XSync() calls is a key performance optimization. Support for this optimization is provided here. Statistics about XSync() calls and latency are gathered in dmxstat.c.

During the initial conversion from calling XSync() immediately to the XSync() batching method implemented in this file, it was noted that, out of more than 300 x11perf tests, 8 tests became more than 100 times faster, with 68 more than 50X faster, 114 more than 10X faster, and 181 more than 2X faster.

## Function Documentation

static void dmxDoSync | ( | DMXScreenInfo * | dmxScreen | ) | `[static]`

References _DMXScreenInfo::beDisplay, dmxStatInterval, dmxStatSync(), dmxSyncPending, and _DMXScreenInfo::needsSync.

Referenced by dmxSync(), and dmxSyncCallback().

void dmxSync | ( | DMXScreenInfo * | dmxScreen,
|  | Bool | now |
| ) |  |  |

Request an XSync() to the display used by dmxScreen. If now is TRUE, call XSync() immediately instead of waiting for the next XSync() batching point. Note that if XSync() batching was deselected with dmxSyncActivate() before dmxSyncInit() was called, then no XSync() batching is performed and this function always calles XSync() immediately.

(Note that this function uses TimerSet but works correctly in the face of a server generation. See the source for details.)

If dmxScreen is NULL, then all pending syncs will be flushed immediately.

References dmxDoSync(), dmxFatal, dmxGeneration, dmxLog(), dmxSyncCallback(), dmxSyncInterval, dmxSyncPending, dmxSyncTimer, _DMXScreenInfo::name, and _DMXScreenInfo::needsSync.

Referenced by _dmxMoveCursor(), _dmxSetCursor(), dmxAddInput(), dmxAttachScreen(), dmxBackendCollectEvents(), dmxBackendProcessInput(), dmxBackendUpdatePosition(), dmxBECreateCursor(), dmxBECreatePixmap(), dmxBELoadFont(), dmxBitmapToRegion(), dmxChangeBorderWidth(), dmxChangeGC(), dmxChangePictureClip(), dmxChangeWindowAttributes(), dmxCheckFontPath(), dmxCheckFontPathElement(), dmxCommonMouOn(), dmxCommonSaveState(), dmxComposite(), dmxCompositeRects(), dmxConsoleCapture(), dmxConsoleUncapture(), dmxCopyArea(), dmxCopyPlane(), dmxCopyWindow(), dmxCreateAndRealizeWindow(), dmxCreateWindow(), dmxDestroyPicture(), dmxDestroyPictureClip(), dmxDestroyPixmap(), dmxDestroyWindow(), dmxDPMSInit(), dmxDPMSTerm(), dmxFillPolygon(), dmxFlushPendingSyncs(), dmxGetImage(), dmxImageText16(), dmxImageText8(), dmxInstallColormap(), dmxPolyArc(), dmxPolyFillArc(), dmxPolyFillRect(), dmxPolylines(), dmxPolyPoint(), dmxPolyRectangle(), dmxPolySegment(), dmxPolyText16(), dmxPolyText8(), dmxPositionWindow(), dmxProcRenderAddGlyphs(), dmxProcRenderCompositeGlyphs(), dmxProcRenderFreeGlyphs(), dmxProcRenderFreeGlyphSet(), dmxProcRenderSetPictureFilter(), dmxProcRenderSetPictureTransform(), dmxPutImage(), dmxRealizeWindow(), dmxReparentWindow(), dmxResizeRootWindow(), dmxResizeScreenWindow(), dmxResizeWindow(), dmxRestackWindow(), dmxSaveScreen(), dmxSetFontPath(), dmxSetShape(), dmxShadowUpdateProc(), dmxStoreColors(), dmxTrapezoids(), dmxTriangles(), dmxTriFan(), dmxTriStrip(), dmxUnrealizeWindow(), dmxValidatePicture(), and dmxWindowExposures().

void dmxSyncActivate | ( | const char * | interval | ) |

Request the XSync() batching optimization with the specified interval (in mS). If the interval is 0, 100mS is used. If the interval is less than 0, then the XSync() batching optimization is not requested (e.g., so the -syncbatch -1 command line option can turn off the default 100mS XSync() batching).

Note that the parameter to this routine is a string, since it will usually be called from ddxProcessArgument in dmxinit.c

References dmxSyncInterval.

Referenced by ddxProcessArgument().

static void dmxSyncBlockHandler | ( | pointer | blockData,
|  | OSTimePtr | pTimeout,
|  | pointer | pReadMask |
| ) |  |  | `[static]`

References dmxSyncTimer.

Referenced by dmxSyncInit().

static CARD32 dmxSyncCallback | ( | OsTimerPtr | timer,
|  | CARD32 | time,
|  | pointer | arg |
| ) |  |  | `[static]`

References dmxDoSync(), dmxNumScreens, dmxScreens, dmxSyncPending, and _DMXScreenInfo::needsSync.

Referenced by dmxSync().

void dmxSyncInit | ( | void |  | ) |

Initialize the XSync() batching optimization, but only if dmxSyncActivate was last called with a non-negative value.

References dmxInfo, dmxLog(), dmxSyncBlockHandler(), dmxSyncInterval, and dmxSyncWakeupHandler().

Referenced by InitOutput().

static void dmxSyncWakeupHandler | ( | pointer | blockData,
|  | int | result,
|  | pointer | pReadMask |
| ) |  |  | `[static]`

Referenced by dmxSyncInit().

## Variable Documentation

int dmxSyncInterval = 100`[static]`

Referenced by dmxSync(), dmxSyncActivate(), and dmxSyncInit().

int dmxSyncPending`[static]`

Referenced by dmxDoSync(), dmxSync(), and dmxSyncCallback().

OsTimerPtr dmxSyncTimer`[static]`

Referenced by dmxSync(), and dmxSyncBlockHandler().

Generated June 29, 2004 for Distributed Multihead X by doxygen 1.3.4. </addres>