CS 485 Systems Programming

Windowing Systems

CS 485 Systems Programming Fall 2015

Instructor: James Griffioen

1 CS 485 Systems Programming

User Interfaces

¢ Terminals § Simple devices connected via serial lines § Character-oriented devices § Support both input and output (keyboard + terminal) § Input/output generates hardware interrupts to the OS on every character ¢ Graphical Users Displays § Replace the simply terminal with a (color) bitmapped display § Display divided into pixels § Color of each pixel is defined by a number § The pixel depth (number of bits per pixel) defines the number of colors supported § The number of pixels in the x and y direcons determines the display’s resoluon. § Add a mouse device as a poinng device § Provides (x,y) coordinates or relave moon § Keyboard connues to provide character input § Keyboard, mouse, and display generate interrupts to the OS § Most displays are now driven by GPUs (graphics processing units) that offload work that would otherwise have to be done by OS/ code running on the CPU.

2 CS 485 Systems Programming

Device Driver Basics

¢ Device drivers handle interrupts from devices ¢ Are device-specific and oen include low-level code wrien in ASM ¢ Oen must handle both input and output interrupts ¢ Data is usually desned for, or coming from, user-level applicaons which requires synchronizaon between the OS kernel device driver rounes and the user-level code that consumes or produces the data. ¢ Buffering is typically supported inside the OS to allow applicaons to run ahead of output or run behind input. ¢ Because buffers are finite, blocking is necessary to prevent buffer overflow.

3 CS 485 Systems Programming

Device Drivers

App

I/O Systems Calls

Kernel I/O Buffer

I/O Handler

CPU MEM TTY

5 CS 485 Systems Programming

Windowing Systems

¢ Are complex pieces of soware § Like the OS, windowing systems have become massive pieces of soware. § In many cases they are ghtly integrated with the OS (i.e., the windowing system is integral to the OS). In other cases windowing system is modular, and can be (easily) replaced with alternave implementaons of the windowing system. ¢ Enhance the device driver of a graphical user display § Provide higher level API calls that applicaons can invoke to manipulate the display. § Provide common “ system abstracons” needed by most applicaons. Examples include text windows, buons, radio boxes, menus, scrollbars, etc. § Hide many of the mouse interrupts from the applicaon, only passing key “events” to the applicaon. For example, mouse moon are oen handled by the windowing system, only passing mouse click events to the applicaon.

6 CS 485 Systems Programming

X Windows

¢ A modular windowing system used on most systems ¢ Developed as part of the Athena project at MIT in the mid 1980’s and was later taken over and supported by the X Consorum. ¢ It is a networked windowing system implying that it can used by remote applicaons ¢ It has a well-defined protocol (the X protocol) that defines the messages that can be sent to, and received from the Windowing system. ¢ A server, knows as the X-server, controls/manages the physical graphical display, rendering images on the display and handling interrupts from the mouse and keyboard. ¢ User applicaons use the network (TCP/IP) to interact with the X-server and create the “windows” required by the applicaon.

7 CS 485 Systems Programming

X window applicaons can run anywhere

Window Window on main on laptop frame

Window Window on on smart super phone computer

8 CS 485 Systems Programming

X-Window Architecture

X Server

Operang System X Display Driver

Hardware

9 CS 485 Systems Programming

X-Window Architecture

X Server

Operang System X Display Driver

Hardware

10 CS 485 Systems Programming

X-Window Architecture

App 1 X Server

Applicaons “speak” Operang System the X protocol to the X server. X Display Driver

Hardware

11 CS 485 Systems Programming

X-Window Architecture

App 1 X Server

Xlib Operang System X Display Driver

Hardware

12 CS 485 Systems Programming

Xlib

¢ A that handles all X communicaon for Applicaons ¢ Supports basic “drawing” operaons § Draw a line at this locaon § Tell me that the mouse moved, or the mouse was clicked § Etc ¢ While it simplifies talking to the X server, it is sll difficult to create the types of nice user interface things that people are used to using (e.g., buons, sliders, etc).

13 CS 485 Systems Programming

X-Window Architecture

App 1 X Server Toolkit Xlib Operang System X Display Driver

Hardware

14 CS 485 Systems Programming

Toolkits

¢ Toolkits are designed to help applicaon create useful graphical user interfaces. ¢ They do not necessary define the “look and feel”, but rather help create the “funconality”. ¢ Toolkits offer common widgets via a “widget library”. Example widgets include buons, scroll bars, radio buons, sliders, etc. They oen also support “canvas” widgets that provide an area of the screen on which other things can be drawn or displayed. ¢ Many different widget libraries and toolkits: § Mof § Gtk § § Xforms § FLTK § LessTif

15 CS 485 Systems Programming

X-Window Architecture

Window Manager

App 1 X Server Toolkit Xlib Operang System X Display Driver

Hardware

16 CS 485 Systems Programming

Window Managers

¢ Window managers manage the way windows look and feel § The way windows are placed on the display § How windows are moved around on the screen § How they are iconified § Possibly defining whether they have tle bars and what features those tle bars support § Etc ¢ Window managers are just X clients like applicaons – albeit special applicaons. ¢ Example Window Managers include: § § § sawfish § kwm § § §

17 CS 485 Systems Programming

X-Window Architecture

Window Manager

App 1 App 2 X Server Toolkit Toolkit Xlib Xlib Operang System Operang X Display Driver System Hardware Hardware

Network

18 CS 485 Systems Programming

X-Window Architecture

Desktop Window Manager

App 1 App 2 X Server Toolkit Toolkit Xlib Xlib Operang System Operang X Display Driver System Hardware Hardware

Network

19 CS 485 Systems Programming

Desktops

¢ Desktops are used to § Define a consistent look and feel across windows § Provide useful services and features (e.g., panels, a visible “desktop” folder, lauch bars, trash, etc.) ¢ Example Desktops include: § Gnome § KDE §

20