| 
						 | 
					||||||||||||||||||||||||||||||||||||||||||||||||||||||
									
									
									Section 1 | 
											Behind the Scenes | 
										
											 | Section 2 | 
											Behind the Scenes, continued | 
										In This Section:Behind the Scenes 
									 As described elsewhere in this book, BeOS is an object-oriented operating system, from its lowest levels to its highest. Wherever possible, code is reused and recycled, rather than re-created from scratch. Each of the system servers described in Chapter 5 dips into its own pool of shared code and doles it out to applications as needed. These pools are divided into broad categories of functions called "Kits," and provide fundamental services (like networking, audio, data translation, and file management) to the system in the cleanest, most efficient way possible. BeOS includes a total of ten Kits; their functions are explored in this chapter. 
									 Behind the Scenes
 
 If you've got two applications open at once and both of them include scrollbars, pulldown menus, resizable borders, and title bars, there's no need for both of them to include all of the code necessary to construct those objects, is there? Of course not. The codebase that describes the rudiments of a basic application is stored at a central location in the operating system. In this way, BeOS achieves maximum efficiency and minimum redundancy, while application developers enjoy the luxury of not having to worry about writing all that stuff themselves. This object-oriented arrangement also ensures a consistency of behavior and appearance throughout the system so that all of your applications look, feel, and behave basically the same way. 
 
 Managing this interplay of services and the code that enables the services are two interrelated constructs: the system servers and the system Kits. You never see the servers or Kits, as they don't have an interface and there's nothing user-configurable about them. The servers (introduced in Chapter 5, Files and the Tracker) are active programs (or "daemons") that lurk in the background, always running, waiting for requests from other programs before springing into action. The servers are compiled, running programs--you can see their icons by opening up your /boot/beos/system/servers folder in the Tracker. The Kits, on the other hand, are not programs at all, and they don't "run" in the background. Rather, they're collections of objects classified by the jobs they do. The concept of "objects" here is a little abstract. In reality, the Kits are defined in shared code libraries that are called upon by all programs, including the servers. There are ten Kits in all, and they collectively define the application programming interface (API) that programmers use to make their generic C++ code talk to and work with the specific aspects of BeOS. They are: 
 
 You'll notice a certain amount of overlap between the list of Kits and the list of servers (for example, there's an Application Kit and an app_server, a Mail Kit and a mail_daemon). But there are also a number of Kits not associated with a server, and vice versa. The relationship is not one-to-one because some of the Kits serve umbrella functions for all of the servers. For instance, the Storage Kit handles the nitty-gritty of reading from and writing to your disks--a job that most of the servers need done in one way or another. Likewise, a Game Kit is necessary for reasons we'll get into later, but games don't require their own server to function. In other words, some Kits are important to all applications, while others come into play only in certain instances. All GUI applications need windows, borders, scrollbars, and menus, so all GUI apps draw on the Application and Interface Kits; but only applications that deal with audio/visual data need to draw on the Media Kit. Finally, all of the servers "sit on top of" the system kernel, interfacing with it directly. 
 
 So how are all of these things related? It sort of depends on your point of view. As an end-user, it may make the most sense to think of the servers as sitting between the kernel and your applications. Servers don't serve you--they serve your applications and your applications serve you. 
 
 From a programmer's point of view, however, it's a little different, as developers don't access the servers directly. They access the Kits from within their code; the Kits in turn know how to talk to the servers. A programmer doesn't say, "Hey network--wake up!", but something more like, "I need a function that can establish a connection to another machine on the network." Since the function called is part of the Network Kit, it automatically establishes communication with the Network Server. Each Kit consists of a collection of "header" files--raw C or C++ code written by Be engineers. When a programmer needs a system service, she invokes a Kit by creating an appropriate object or "including" the appropriate header file and invoking the appropriate function. If you'd like to study more technical documentation on BeOS's system Kits, it's right there on your hard drive, at /boot/beos/documentation/BeBook/. There you'll find a collection of folders, each named for a separate Kit. Each folder contains a series of HTML documents describing that Kit in detail (though not always in plain English). The Application KitThe Application Kit is the most foundational of all the Kits--without it, you simply don't have a GUI application. The invocation of the Application Kit is the moment of conception for a BeOS application. By invoking the Application Kit, an application basically blinks into existence--it gains an identity and becomes known to the system. It gets registered in the Deskbar and can be referred to and communicated with by its application signature. The Application Kit consists of four major parts. 
 
 
 
 Messaging The Application Kit allows programs to spawn threads (see Glossary and/or Chapter 2, Meet the System), and those threads to become the bearers of BMessages (Chapter 1), enabling them to communicate with one another and with the threads of other running applications. It also handles "event messages," keeping track of mouse clicks, keypresses, and infrared signals from your garage door opener. The BApplication Class By creating (or, more correctly, "instantiating") a BApplication class, the Application Kit makes its connection with the application server, which takes over common tasks like monitoring system resources, drawing images in windows, resizing borders, and lording over the cursor. Every BeOS application must include a single instance of this class. The BRoster Class BeOS maintains at all times an internal roster of all running applications. Programmers can query this roster to learn which applications are currently available for communication. By registering themselves in the system roster, applications provide the data other programs need to establish communications. The BClipboard Class This class handles the transfer of data to and from the system clipboard any time you cut, copy, or paste text, images, spreadsheet rows, or anything else. The Storage KitWe took a hard look at BFS (the Be Filesystem) in Chapter 5, Files and the Tracker, and discussed its many unique properties: journaling, attributes, node monitors, symbolic links, virtual filesystems, queries, and more. BFS is fine-tuned to handle high-bandwidth multimedia files with maximum throughput while at the same time offering the average user database-like functionality not available on any other system. The Storage Kit is the mechanism through which programmers instruct their applications to take advantage of these features. Of course, it's also responsible for the more mundane act of simply reading files from and to disk volumes. Needless to say, the Storage Kit works closely with the storage server to create and recognize files, directories, links, and attributes. Like the Application Kit, the Storage Kit is divided into four major functions. Maintaining the Filesystem and Navigating Hierarchies While you can mount any number of disk drives on your system, each of these drives can contain multiple partitions, and these partitions can in turn support various filesystems, the totality of all mounted partitions appears as a single logical hierarchy when viewed by the Tracker, or when referred to from within programs. As you add or subtract partitions, the hierarchy maintains its integrity. The collection of all mounted partitions on your machine is referred to as "the filesystem." Note, however, that this term is a little confusing, since the term "filesystem" also applies to the low-level layout and formatted structure of a disk platter. One term, two meanings. Maintaining and communicating with the collective filesystem is the chief job of the Storage Kit. Because BeOS uses a plug-in architecture that allows it to recognize filesystems from other operating systems, it must make at least one fundamental assumption about how those filesystems will be organized: BFS requires that any recognized filesystem will be hierarchical in nature, using a tree-like structure that fans out from a single root into a system of boughs, branches, and leaves (folders and files). Since virtually all filesystems out there are structured in this way, BeOS's potential support of alien filesystems is practically universal. Under this umbrella fall dozens of related responsibilities. Reading and Writing Files and Directories The function of the Storage Kit that is perhaps most visible to the user is the task of creating, deleting, naming, renaming, copying, moving, and otherwise managing the collection of mounted files and folders. This job is accomplished by way of two fundamental filesystem concepts: "nodes" and "entries." A node is an actual file--the data in your address book, for example. But it's not enough to simply scatter a disk with file data; something must keep track of what lives where so the filesystem can be constructed visually in the Tracker and reported accurately in the Terminal. Entries represent the locations of nodes. However, the relationship between nodes and entries is not necessarily one-to-one. While every node must have an entry, it is possible to have entries without nodes. For instance, an application might create an entry in the filesystem as a placeholder, before the file has actually been created. As you might expect, the onus of maintaining MIME types and attributes (Chapter 5, Files and the Tracker) also falls on the shoulders of the Storage Kit. From the perspective of the BFS, attributes are essentially normal files, and have their own nodes and entries. But from the perspective of the Tracker and the Terminal, attributes are not displayed in file listings (by default, though you can of course customize any Tracker view to display an array of related attributes--see Chapter 2, Meet the System), nor are their sizes reported to the user, so a distinction must be made between them. Since the Storage Kit is responsible for all reading and writing of attributes and MIME types, the system FileTypes database (page 272 in Chapter 5) also falls under its rubric. Monitoring Changes (Node Monitor) There are many instances in which it's useful for an application to be able to keep a watchful eye on a file or folder to see when it's been updated so it can take some kind of action. The mechanism that accomplishes this act of voyeurism is called the "node monitor." A simple example of the node monitor in action is the Trash icon on your desktop. As described in Chapter 5, the Trash is a special folder in a number of ways. One of its distinguishing characteristics is its ability to wear a different icon depending on whether it's empty or full. Because a node monitor is permanently trained on the Trash, dragging a file into the empty Trash bin will kick its node monitor into action, and the Trash icon will immediately change. The Tracker uses node monitors in all folder views--this is why making a change to the contents of a folder from the Terminal will cause the folder view in the GUI to be updated instantaneously. Application developers can employ node monitors in all kinds of creative ways. Node monitors are related to files and folders at the lowest level, so they're handled by the Storage Kit. Asking for Files (Requests and Queries) Files don't do anyone any good if they can't be retrieved by applications. Even if it seems like the most trivial task, requesting a file from a disk volume is one of the Storage Kit's most important jobs. There's more to this category than meets the eye, however. Requesting files from disk involves communicating with high-level system objects such as the familiar File panel and the Tracker list view, as well as more abstract functions, such as finding the current directory's parent, obtaining the full path of a file, or hoovering a file's custom icon out of its attributes. The act of querying the system for files that meet certain criteria is another Storage Kit task falling under this umbrella. As intuitive as it may seem to our human brains, scanning the system for all files that begin with a capital "M" requires a substantial amount of work from BeOS. In addition, the Storage Kit needs to maintain queries in a "live" state so that the results window updates itself when files suddenly meet (or stop meeting) your criteria. Real-time updating of virtually everything is "the BeOS way" and is accomplished at the filesystem level by the labors of the Storage Kit. 
 
  | 
							||||||||||||||||||||||||||
| 
												 | 
											next >> | 
![]()  | 
							
![]()  | 
							
Please direct technical questions about this site to webmaster@peachpit.com.
Copyright © 1999 Peachpit Press and the respective authors.