ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Reentrancy in QDGX Printer Drivers


Important for all Apple Printing and Graphics Developers:

The information in this Technical Q & A is still relevant up to and including Mac OS 7.6 with QuickDraw GX 1.1.5. Beginning with the release of Mac OS 8.0, however, Apple plans to deliver a system which incorporates QuickDraw GX graphics and typography only. QuickDraw GX printer drivers and GX printing extensions will not be supported in Mac OS 8.0 or in future Mac OS releases. Apple's goal is to simplify the user experience of printing by unifying the Macintosh graphic and printing architectures and standardizing on the classic Printing Manager.

For details on Apple's official announcement, refer to </dev/technotes/gxchange.html>

Q: I am writing a QuickDraw GX printer driver that supports SCSI and Server connection types. I can connect multiple printers to one Mac on the SCSI bus, and I have seen that I can have active print jobs printing on all of them simultaneously.

Do I have to be concerned about reentrancy when coding my message overrides?

A: There are a few issues you'll need to keep in mind.

One is that each copy of your driver must store any data it needs in its own data space. You can do this by using the GetMessageHandlerInstanceContext and SetMessageHandler-InstanceContext functions. If there is common global data that all copies of your driver will need to access, you can use the SetMessageHandlerClassContext and GetMessageHandlerClassContext functions. These are documented in Chapter 6 of Inside Macintosh: QuickDraw GX Environment and Utilities.

For each instance of your driver, you'll also need to watch out for insufficient memory. You shouldn't need to add much code if you are already checking for error conditions when attempting to allocate memory within your driver, but if there are places where you're not checking to make sure that the allocation was actually successful, you'll need to add code (it's a good idea to always check anyhow).

You will also need to confirm that you don't have multiple instances of your driver trying to write to the same DTP at the same time. There are any number of ways you can implement this, including using a shared (ClassContext) data block with a semaphore to mark whether an instance of your driver was in the middle of a GXWriteDTPData call. Each instance could then first check that semaphore before attempting to read or write data from the DTP. Be sure to include file-locking while your driver is reading or writing other files.

Additionally, if you are writing a PostScript driver, be aware that the PostScript font downloading code is not reentrant.

In general, you should use these techniques to write any QuickDraw GX print driver, whether you expect it to need to worry about reentrancy or not.

[Feb 09 1996]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.