## Physical Device Driver Reference

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

### Monitor Thread Priorities

To guarantee steady and reasonably fast data throughput in a monitor chain in this multithreaded, multitasking environment, the priority of monitor threads must be set high. Because character device monitors are part of a data stream, they must process data records rapidly so that they do not delay I/O. A monitor application must be written so the threads that actually read and write the monitor data run at a high priority. They must never perform operations such as I/O or semaphore waits that might cause excessive delay. The monitor application can have other threads running at normal priorities to handle such functions.

Threads responsible for moving keystroke data through a monitor chain must pay special attention to the thread priority. Keystroke monitor threads must execute within the time-critical priority class. More specifically, these threads must execute at a priority level greater than or equal to the lowest level in the time-critical priority class. The preferred level is Level 0. This applies to any threads that read (DosMonRead), process, or write (DosMonWrite) keystroke monitor data. In addition, the thread that makes the call to DosMonReg must also be executing in the time-critical priority class.

A monitor application can call DosCreateThread to create separate threads to intercept data from, and return filtered data to, a monitor chain. The application must also set the priority of these threads by calling DosSetPrty. See the OS/2 Control Program Programming Reference for descriptions of the DosCreateThread and DosSetPrty functions for more information concerning creating threads and priority classes.