## Printer Device Driver

[prev][next][parent][TOC]

### Output-Thread Management

The output-thread management module provides a way to create multiple output threads that will manage the sending of data buffers to the printer. This functionality has also been called second-thread code; however, the implementation allows a separate thread per physical output address (for example, LPT, COM, and file).

This package seamlessly manages multiple buffer allocations and chains them together. It adjusts the internal data buffering to always try to keep the printer busy processing data. The functions assure that buffer sizes and their reuse align for the best performance with the system-memory memory model (for example, the OS/2 paging architecture).

Note: You may override the default buffer size and the maximum number of buffers to create.

Other benefits of using the separate output-thread code in your driver include:

Ability to pass off data buffers as fast as you can fill them without waiting for a device with slower transfer speeds

Unknowingly, the OS/2 PM graphics engine (and other system components) might have locked down system resources, such as fonts, while calling your driver. Therefore, implementing the thread code allows you to return to the graphics engine and free up the resource for other parts of the system, such as the display. This makes the system and applications more responsive to the user.

The package uses the GenPLib Exception-Management package for simple debug tracing.

The package uses the GenPLib Memory-Management package for allocation of instance data.

To use the GenPLib Output-Thread Management package, you must include:

    INCL_GENPLIB_THREAD

Following are the Output-Thread Management APIs:

GplThreadCreateInstance
GplThreadStart
GplThreadOutput
GplThreadEnd
GplThreadDeleteInstance
GplThreadAbortDoc
GplThreadResetAbortDoc
GplThreadFlushBuffer
GplThreadHookDeviceWrites