Tired of hard-wiring Windows for multiple processes? Photon lives for event-driven applications for PDAs, process control, and data acquisition.
Peter D. Varhol
A friend of mine is searching in vain for the Zen of Windows. He seeks a way to magically fit together all the individual and often disjointed pieces of Windows programming into a coherent whole. This enlightened programming model would yield an intuitive feel for Windows applications design. APIs would be simple details that you look up as you need them.
His search has been futile because the Windows programming model is fundamentally incoherent. He'd have far more luck if he turned his attention to Photon, the new windowing environment for QNX, where coherence is as natural as the air on Mt. Fuji.
Photon gives developers a great
deal of control over how processes respond to events. Best of all, this control is built into the architecture rather than being something that a developer must add, as in Windows. The Photon windowing model depicts processes and events that programmers must take into account when developing applications for a windowing system (see "The Photon Architecture"). This type of control is important for specialized applications ranging from a handwriting-recognition program for PDAs (personal digital assistants) to applications for data acquisition and process control devices.
Photon is an optional module for QNX, a Posix-compliant real-time OS (see "QNX Forges Ahead," October 1994 BYTE). In about 650 lines of code, the 10-KB QNX microkernel performs IPC (interprocess communications) locally and over a network, process scheduling, and interrupt redirection. You need only about 14 system calls to access these services. QNX is a message-passing OS that doesn't distinguish between local and remote messages. This
is one feature that makes it an excellent distributed OS.
Photon is built on these same principles. The Photon microkernel is a resource manager that creates a graphical event space and manages regions and events in that space. The Photon microkernel is about 24 KB of code plus 40 KB of data. Extra components, such as shared libraries and drivers, might increase the amount of code and data to about 250 KB. The Photon Window Manager adds 24 KB of code and 48 KB of data.
In addition to Photon, QNX offers as an option a full X11R5 implementation of the X Window System, with the Motif window manager, scalable fonts, and font server. X uses the QNX message passing for communication between QNX kernels and uses TCP/IP for communication with other X servers.)
QNX runs its device drivers as user processes, which means you can dynamically load drivers when you need them. For example, Photon and X may require a mouse driver, and X may need to access a CD-ROM drive. To load these, you simply type
Mouse msoft </dev/ser1
for a Microsoft serial mouse, and
Fsys.Aha4scsi
for an Adaptec-compatible SCSI CD-ROM drive. The drivers load into user space, find the devices, and make them available to the system. Running drivers in the user space provides MMU (memory management unit) protection for user processes. Also, you can use a full screen source code debugger to debug device drivers. You might think that running device drivers in user space causes unacceptable performance penalties, but we haven't noticed any problems with the QNX applications we have built.
Photon is remarkably easy to install for a Unix-like product. We just loaded the requisite drivers from the command line, called the install program on the floppy or CD-ROM drive, and launched the program. Because QNX runs everything as a process, we only had to rebuild the kernel when we upgraded the base OS.
How easy is Photon to use? The first time we used Photon, its application-builder module wouldn't launch. But a
fter taking a quick trip through the Photon documentation, we discovered that we had to run Photon in Super VGA mode. We then simply returned to the QNX command line, ran the Super VGA driver, and returned to Photon.
Windows for the Masses
If programmers use the Photon model depicted at left, there should be no question about the behavior of their process in response to events. Furthermore, programming becomes more straightforward because the model is consistent and easily extensible without much effort. Our experience with Photon backs that up: We wrote a resource-scheduling application in only about 100 lines of code.
While it is natural to compare Photon to a general-purpose windowing system like Windows, the comparison may be a poor one. Photon is not designed for general-purpose use, and it has fewer APIs than Windows or other known systems. The Photon event model may not be widely usable in general-purpose computing. Imagine a transparent process that automatically
passes mouse-clicks through to other applications. Without controlling or even knowing about the behavior of all running applications, such a process can wreak havoc.
Photon is designed for an application environment that is more controlled than a Windows application environment. A Photon programmer of one process should know what other processes are running under the windowing system. Therefore, events for one process will not be mistakenly intercepted by others.
But the behavior of processes in Photon defaults to the opaque value of the opacity property (see the "Process Region" icon in "The Photon Architecture"), so under normal circumstances, it behaves like Windows or X (Photon defaults to Motif window manager).
If you want to do something unusual, you have to adjust the properties of the processes. For example, in a process control application, you might want a series of different processes to simultaneously receive the same mouse-click signal. In this instance, you probably don't
also want to run Photon as a general-purpose windowing system.
Photon need not run on the same system as its processes. Some developers are even running Photon under Windows on separate systems simply by passing process events to and from the Photon manager, which runs as a Windows process.
Photon uses a coherent model of process interaction in an event-driven environment. If your benchmark is Windows or a general-purpose windowing system, you can appreciate QNX and Photon as being small and elegant operating environments for process-control and real-time systems. As Photon develops, we may see it appear on more desktops as an alternative windowing system.
PRODUCT INFORMATION
QNX...........................$795
Photon........................$95
QNX Software Systems, Ltd.
Kanata, Ontario, Canada
(800) 676-0566
(613) 591-0931
fax: (613) 591-3579
Http://WWW.QNX.com
FTP.QNX.com:/pub/papers
Peter D. Varhol is chair of the graduate computer science department at Rivier College in Nashua, New Hampshire. You can reach him on the Internet or BIX at
pvarhol@bix.com
.