Presentation is loading. Please wait.

Presentation is loading. Please wait.

X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Similar presentations

Presentation on theme: "X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)"— Presentation transcript:

1 X Ricardo A. Baratto NCL

2 Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

3 System Overview History Created in 1984 in MIT. X11 released on 1987 (latest R6.6 - April 2001) The system X clients (Xlib) X protocol X server

4 System Overview (cont...) Features Event Driven Network Transparent Device Independent Policy Independent Extensible

5 X Protocol Communication Client – Server Object based Asynchronous Types of Messages: Request (Client -> Server) Reply Event (Server -> Client) Error

6 X Server Does Process Output Process Input Extension Mechanism Doesnt Define User Interface (X Toolkits) Window Management (WM) Each client responsible for its windows (Backing store) Interpret input (Input Methods – Input Server)

7 X Server (cont…) Manages a Display Screens (physical monitor) Input Devices Everything is a window Cheap, unlimited Tree structure Root window: Complete screen Top-level windows: main app window Parent window clips children

8 X Server Architecture Layered DIX: Device Independent DDX: Device Dependent Extensions Everything controlled through resources Screens, GCs, windows, pixmaps, regions, colormaps, fonts, cursors Created on demand Used by clients to request operations -> Use ID

9 Dispatch Loop Heart of X server processing (DIX) Process client requests Send input events Looks like: for(;;) nready = WaitForSomething(…); while(nready--) while(!isItTimeToYield) if(!ReadRequestFromClient(…)) break; (execute request);

10 Dispatch Loop (cont…) Requests serviced round-robin Execs up to 10 requests from every client Problems Busy client can monopolize server select() not called often enough Busy clients are not managed efficiently select() called too often

11 Dispatch Loop (cont…) Fix: XFree86 smart scheduler Use time metric, not request-count metric Dedicate time slice to each client Gather many clients on every iteration Poll, dont block Delay yielding Give clients a second chance Prioritize clients Penalize busy, praise user preferred

12 Screens One for each physical screen ScreenRec structure Defines functions used to handle operations on resources Main communication channel DIX-DDX

13 Drawables Where drawing takes place Windows Used for display output May have own colormap Pixmaps Off-screen – own depth Used to speed up operations

14 Graphic Contexts Describe how to draw Colors (fg, bg), fonts, line width, … Normally set up once, used by many Stored in server Requests specify GC, drawable and what to draw

15 Porting X Server Code layers DIX -> Dev.Independent, dont 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

16 OS Layer Maintain client connections Schedule work to be done for clients Ignore/AttendClient() File and memory management Fonts stored in files Xalloc()/Xrealloc()/Xfree()

17 WaitForSomething() Input events from user or hardware SetInputCheck() Requests pending from existing clients ReadRequestFromClient() New client Access control -> ClientAuthorized() Create it -> NextAvailableClient()

18 DDX Layer Input Processing Mouse movement Key presses Key mappings Graphics Display

19 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

20 Output Initialization InitOutput() Process arguments Discover screens AddScreen() Initialize pixmap formats Additional implementation dependent stuff

21 DDX Drawables Fields Serial number, depth, size and position Procedures to manipulate them Private DDX data Pixmaps Rectangular array of pixel values Reference counted Bitmaps are depth-1

22 DDX Drawables (cont…) Windows Visible rectangle on screen Border drawn by DDX Create, move, resize Contents drawn by client Expose Events Server may provide backing store Bit gravity (resizing) Clipped by parent and sibbling windows

23 DDX 2D Graphics Procedures for drawing primitives Lines, arcs, arc filling, text drawing Clients may allow DDX optimizations e.g. Zero-width lines GC defines how to draw primitives May use MI functions Need only define basic Pixblit routines Read/write pixel values & deal with image data

24 XFree86 Device Drivers Lifes easier Another abstraction layer Most previous procedures already defined Drivers are loadable modules Need not distribute/recompile whole server Module format X specific OS/Architecture independent Additional formats supported (dlopen())

25 Device Drivers (cont…) Define only device specific routines Discovery of devices (PCI/ISA access) Device Initialization Device Drivers have access to ScreenRec Can redefine resource procedures Optimize for display hardware Sample VGA device driver Provides basic functionality usable by others Interface still unstable

Download ppt "X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)"

Similar presentations

Ads by Google