X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process...
-
Upload
skyler-lumbard -
Category
Documents
-
view
217 -
download
1
Transcript of X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process...
X
Ricardo A. Baratto
NCL
Overview
System overview
X protocol
X serverArchitecture
Porting process
XFree86 (device drivers)
System Overview
HistoryCreated in 1984 in MIT.
X11 released on 1987 (latest R6.6 - April 2001)
The systemX clients (Xlib)
X protocol
X server
System Overview (cont...)
FeaturesEvent Driven
Network Transparent
Device Independent
Policy Independent
Extensible
X Protocol
Communication Client – ServerObject basedAsynchronousTypes of Messages:
Request (Client -> Server)ReplyEvent (Server -> Client)Error
X Server
DoesProcess Output
Process Input
Extension Mechanism
Doesn’tDefine User Interface (X Toolkits)
Window Management (WM)
Each client responsible for its windows (Backing store)
Interpret input (Input Methods – Input Server)
X Server (cont…)
Manages a DisplayScreens (physical monitor)
Input Devices
Everything is a windowCheap, unlimited
Tree structure
Root window: Complete screen
Top-level windows: main app window
Parent window clips children
X Server Architecture
LayeredDIX: Device Independent
DDX: Device Dependent
Extensions
Everything controlled through resourcesScreens, GCs, windows, pixmaps, regions, colormaps, fonts, cursors
Created on demand
Used by clients to request operations -> Use ID
Dispatch LoopHeart of X server processing (DIX)
Process client requestsSend input events
Looks like:for(;;)
nready = WaitForSomething(…);while(nready--)
while(!isItTimeToYield)if(!ReadRequestFromClient(…))
break;(execute request);
Dispatch Loop (cont…)
Requests serviced round-robinExecs up to 10 requests from every client
ProblemsBusy client can monopolize server
select() not called often enough
Busy clients are not managed efficientlyselect() called too often
Dispatch Loop (cont…)
Fix: XFree86 smart schedulerUse time metric, not request-count metric
Dedicate time slice to each client
Gather many clients on every iterationPoll, don’t block
Delay yieldingGive clients a second chance
Prioritize clientsPenalize busy, praise user preferred
Screens
One for each physical screen
ScreenRec structure
Defines functions used to handle operations on resources
Main communication channel DIX-DDX
Drawables
Where drawing takes place
WindowsUsed for display output
May have own colormap
PixmapsOff-screen – own depth
Used to speed up operations
Graphic Contexts
Describe how to drawColors (fg, bg), fonts, line width, …
Normally set up once, used by manyStored in server
Requests specify GC, drawable and what to draw
Porting X Server
Code layersDIX -> Dev.Independent, don’t touch
OS -> OS specific
DDX -> Graphics Device specific
Extensions -> Add features
Porting Layer: OS + DDX
Porting process:Define functions required by DIX to handle resources
OS Layer
Maintain client connections
Schedule work to be done for clientsIgnore/AttendClient()
File and memory managementFonts stored in files
Xalloc()/Xrealloc()/Xfree()
WaitForSomething()
Input events from user or hardwareSetInputCheck()
Requests pending from existing clientsReadRequestFromClient()
New clientAccess control -> ClientAuthorized()
Create it -> NextAvailableClient()
DDX Layer
Input ProcessingMouse movement
Key presses
Key mappings
Graphics Display
Graphics Output
Pixel based
Screen basic data structure
Manage all resources
Output done on drawables
Pixel data format defined by DDX
Pixmap format constant across screens
XYPixmap -> one bitmap for each plane
Zpixmap -> series of pixel values
Pixel values interpreted at display time
Output Initialization
InitOutput()Process arguments
Discover screensAddScreen()
Initialize pixmap formats
Additional implementation dependent stuff
DDX Drawables
FieldsSerial number, depth, size and position
Procedures to manipulate them
Private DDX data
PixmapsRectangular array of pixel values
Reference counted
Bitmaps are depth-1
DDX Drawables (cont…)
WindowsVisible rectangle on screenBorder drawn by DDX
Create, move, resize
Contents drawn by clientExpose EventsServer may provide backing storeBit gravity (resizing)
Clipped by parent and sibbling windows
DDX 2D Graphics
Procedures for drawing primitivesLines, arcs, arc filling, text drawing
Clients may allow DDX optimizationse.g. Zero-width lines
GC defines how to draw primitivesMay use MI functions
Need only define basic Pixblit routinesRead/write pixel values & deal with image data
XFree86 Device Drivers
Life’s easierAnother abstraction layer
Most previous procedures already defined
Drivers are loadable modulesNeed not distribute/recompile whole server
Module format X specificOS/Architecture independent
Additional formats supported (dlopen())
Device Drivers (cont…)
Define only device specific routinesDiscovery of devices (PCI/ISA access)Device Initialization
Device Drivers have access to ScreenRecCan redefine resource proceduresOptimize for display hardware
Sample VGA device driverProvides basic functionality usable by others
Interface still unstable