Archives
 
 
 
  Special
 
 
 
  About Us
 
 
 

Newsletter
Free E-mail Newsletter from BYTE.com

 
    
           
Visit the home page Browse the four-year online archive Download platform-neutral CPU/FPU benchmarks Find information for advertisers, authors, vendors, subscribers Request free information on products written about or advertised in BYTE Submit a press release, or scan recent announcements Talk with BYTE's staff and readers about products and technologies

ArticlesEssential Reading


April 1994 / Hands On / Essential Reading

Four recommended books on Windows NT, Win32, and OLE 2

Jon Udell

Among the recent profusion of Windows NT books are four that I've found especially interesting: Martin Heller's Advanced Win32 Programming, Jeffrey Richter's Advanced Windows NT, Russ Blake's Optimizing Windows NT, and Kraig Brockschmidt's Inside OLE 2.

Heller Investigates Win32

Advanced Win32 Programming isn't a Win32 encyclopedia. Instead, it's a personal memoir that chronicles how a seasoned Windows programmer--Martin Heller--evolved into a Win32 programmer. Because C++ is fast becoming the lingua franca of Windows, he investigates that as well. "I'm the last person who should teach C++," Heller says, "as I've fought it, kicking and screaming, for years."

That's precisely what makes his assessment of C++ so intriguing. Like many Windows prog rammers, he's torn between wanting to learn object-oriented programming and having to get software out the door. The tension between desire and duty yields a refreshingly candid analysis of the benefits of C++. Because this is, after all, a book about porting from Win16 to Win32, the discussion leads naturally to MFC (Microsoft Foundation Classes), which hide many differences between the two.

One of the book's core examples is an image-viewing program that first appeared in Heller's earlier Advanced Windows Programming. A first pass through that code yields a quick-and-dirty Win32 version of the program. A second pass turns it into a quick-and-dirty C++ version. A third pass, intended to make it a truly object-oriented program, wanders entertainingly around in the MFC framework exploring document and view classes and their bit-map-related derivatives. However, it ultimately never delivers the promised object-oriented result. A cop-out? "I learned an awful lot along the way," Heller says now. So does th e reader.

Other topics are advanced graphics (i.e., Bˇzier curves, paths, and world transforms), thread synchronization, Win32s and universal thinking, the multimedia subsystem, enhanced metafiles, and networking (i.e., WNet APIs, named pipes, NetDDE, sockets, and RPCs [remote procedure calls]). Heller picks an eclectic variety of subjects and dissects them in a literate and engaging way.

Richter on Win32

Advanced Windows NT by Jeffrey Richter is a Win32 encyclopedia, more specifically a detailed guide to the most interesting and important Win32-only APIs. Highlighted subjects include thread synchronization, heap and virtual memory management, memory-mapped files, DLLs, asynchronous I/O, structured exception handling, and Unicode. Every chapter is enlightening, and the book is packed with concise code samples that isolate the APIs of interest.

How does the multithreaded C run-time library work, and why are both single-threaded and multithreaded versions necessary? Why are the heap APIs useful? When should you use sparse virtual memory? Richter's methodical research yields authoritative answers to these and many other questions.

The best client of the Win32 services is Windows NT itself, and Richter often motivates the discussion by showing how NT uses Win32 features to get its job done. Memory-mapped files and thread-local storage, for example, aren't just conveniences for the applications programmer. NT uses memory-mapped files to optimize program loading; thread-local storage is used so the multithreaded C run-time library can store per-thread data. Insights like these make Advanced Windows NT more than an API cookbook. It greatly enriched my understanding of the base operating system as well.

Two extended examples will prove especially valuable to students of Win32. A supermarket simulation nicely demonstrates the use of both semaphores and mutexes in a complex synchronization scenario involving lots of threads. A file-copying example highlights NT's potent asynchronous I /O features, contrasting the extended (i.e., alertable) read, write, and wait functions with their standard (i.e., nonalertable) counterparts.

Much of this Win32 exegesis applies not only to NT, but also to Chicago. So even if Windows NT isn't part of your current plan, there are still compelling reasons to get up to speed on threads, sparse virtual memory, memory-mapped files, and other Win32 features common to NT and Chicago. Richter offers comprehensive and reliable guidance.

Blake on Performance Monitoring

Optimizing Windows NT documents the use of the NT Performance Monitor in exhaustive detail. That's a subject Russ Blake knows intimately--he not only wrote the book, but also the tool itself. On another level, the book is a profound meditation on how to identify and eliminate performance bottlenecks in computer systems. Finally, it's a tribute to the first-class instrumentation that's built into Windows NT.

The object-based architecture of NT gave its designers convenient hooks o n which to hang counters that monitor the system's vital signs as it runs. For each class of system object--processor, process, thread, cache, disk, network transport, and others--NT maintains a variety of counters that measure the usage of objects of that class. Performance Monitor retrieves the numbers and displays them as charts and tables.

Optimizing Windows NT shows how a savvy user of Performance Monitor can gain extraordinary insight into the dynamics of a running NT system. In Blake's hands, the data clearly exposes system bottlenecks and enables him to state with certainty that a given system's upgrade dollars should be spent on a faster disk, more disks, more memory, or a better network adapter. To show the rest of us how to interpret the data as effectively, Blake works through dozens of examples. Along the way, he teaches an entire methodology of performance analysis and animates the inner workings of NT: the working set tuner, the cache manager, and the scheduler.

Applications can c reate their own counters for use by Performance Monitor--SQL Server does, for example. The ability to unify application and system counters is one of the things that makes Windows NT such a compelling platform for high-performance applications. To illustrate how to create application-specific counters, Blake modifies the sample VGA driver from the DDK (Device Driver Development Kit), adding counters for BitBlt and text operations.

The technique is relatively arcane. While Performance Monitor queries the registry to collect data (other applications can, too), those queries vector through "performance library" DLLs that in turn communicate with applications. The sample code provides a framework that will make adding your own counters doable, although admittedly not trivial.

I hope Microsoft generalizes this technique at some point, perhaps as part of MFC. Widespread use of such a framework would usher in a generation of applications that benchmark themselves continuously, as NT does, and that woul d be invaluable.

You wouldn't think that hundreds of pages of NT performance analysis would make for a readable book. Surprisingly it does, thanks in part to Blake's irrepressible humor. "To determine the precise location of the bottleneck in your computer, you must become as one with the computer," he jests. "To achieve this state requires years of meditation, prayer, and insanity." He goes on to say that NT's careful instrumentation lays the foundation for a sane approach to the analysis of system and application performance. I wholly agree.

Brockschmidt on OLE 2

Inside OLE 2 can't really be considered an NT book, because the NT version of OLE 2 has yet to ship. On the other hand, OLE plays an even bigger role in Cairo (NT's successor) than in Chicago (Windows 3.1's replacement). Cairo's shell is made up entirely of user-modifiable OLE objects. Initially pegged as a compound-document technology, OLE 2 turned out to be something far more ambitious: Microsoft's foundation for object-oriented Windows.

The design of object-oriented operating systems is a hot topic right now. Taligent, IBM, Sun, Next, and Hewlett-Packard are advancing their own initiatives and forming alliances with one another. Thus, Kraig Brockschmidt's thousand-page manifesto is essential reading not only for the Windows crowd, but for anyone who needs to evaluate the kind of object system Windows is becoming.

OLE 2 is big and scary, and Brockschmidt doesn't pretend otherwise. Undaunted, he lays out the architecture of the Component Object Model at the heart of OLE 2 and then explores key interfaces, including structured storage, data transfer, embedding, and in-place activation.

A controversial aspect of the OLE 2 Component Object Model is that it tosses inheritance in favor of an alternative scheme called aggregation. Brockschmidt's argument for aggregation--that it's the most reliable way to preserve rigorous contracts among components--will receive close scrutiny. Microsoft's approach to reusable componen ts could well prove out. The current plan reflects important lessons learned from the VBX (Visual Basic extensions) experiment, arguably the most successful component architecture to date.

But I'm not yet wholly convinced, in part because Brockschmidt's explanation of the rules for implementing aggregation makes my head spin. Significant encapsulation of that mechanism will be required before most programmers will be able to consider using it. Of course, C++ will be the most likely means of encapsulation. He shows how C++ and OLE 2 can work together. The sample applications that evolve chapter by chapter from straight Windows to OLE 2 are written in terms of a homegrown C++ application framework and, in fact, make good use of inheritance.

When you control the source code, inheritance works well, Brockschmidt argues. But when you don't, inheritance cannot support effective reuse. Perhaps when some future version of MFC does for aggregation what MFC 2.5 now does for in-place activation and OLE aut omation, we'll find out whether aggregation works as advertised.

The book does make a convincing case for less abstract OLE 2 technologies that you can apply now. If you use the structured-storage interfaces, you can tap features of a next-generation file system, including transactioning and object persistence. If you implement data objects, they will unify Clipboard, drag-and-drop, and other modes of data transfer.

Detailed explanations show how to convert standard Windows code into OLE 2 code. The mechanics of DLL versus .EXE object implementations, and the merits of object handlers and in-process servers (both DLL-based), and local servers (.EXE-based), are also explored in detail.

Does anyone need to know all this, given that frameworks like MFC 2.5 will hide this complexity from even experienced programmers? Yes. Competent users of an abstraction need to know what lies behind it. Also, the technologies that make up OLE 2 define the future of Windows as an object-oriented operating sy stem. That future is clearly discernible in Inside OLE 2.


Illustration: Advanced Windows NT by Jeffrey Richter, Microsoft Press, $39.95, 700 pp., ISBN 1-55615-567-0 (one disk).
Illustration: Advanced Win32 Programming by Martin Heller, John Wiley & Sons, $44.95, 463 pp., ISBN 0-471-59245-5 (one disk).
Illustration: Optimizing Windows NT by Russ Blake, Microsoft Press, $34.95, 581 pp., ISBN 1-55615-600-6 (one disk).
Illustration: Inside OLE 2 by Kraig Brockschmidt, Microsoft Press, $49.95, 977 pp., ISBN 1-55615-618-9 (two disks).
Jon Udell is a BYTE senior technical editor at large. You can reach him on the Internet or BIX at judell@bix.com .

Up to the Hands On section contentsGo to previous article: Developing Applications in PerlSearchSend a comment on this articleSubscribe to BYTE or BYTE on CD-ROM  
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it is theoretical--and no language better exemplifies this than C++.

more...

BYTE Digest

BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin, and dozens of other CMP publications—bringing you critical news and information about wireless communication, computer security, software development, embedded systems, and more!

Find out more

BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE Volume 1: Programming Languages
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...

Copyright © 2005 CMP Media LLC, Privacy Policy, Your California Privacy rights, Terms of Service
Site comments: webmaster@byte.com
SDMG Web Sites: BYTE.com, C/C++ Users Journal, Dr. Dobb's Journal, MSDN Magazine, New Architect, SD Expo, SD Magazine, Sys Admin, The Perl Journal, UnixReview.com, Windows Developer Network