## The POLLING Sample

The POLLING Sample accompanies Chapter 14 and illustrates how to use a system thread to manage a polled device.

The sample includes two components:

- POLLING.SYS (SYS subdirectory) is a WDM driver for a non-existent hardware device.
- TEST.EXE (TEST subdirectory) is a Win32 console application that tests POLLING.SYS.

### Building POLLING

To build POLLING.SYS, follow the general instructions for building a WDM sample. The Microsoft Visual C++ project file is named POLLING.DSP in the SYS subdirectory.

To build TEST.EXE, follow the general instructions for building user-mode programs. The Microsoft Visual C++ project file is named TEST.DSP in the TEST subdirectory.

### Testing POLLING

To test POLLING, follow the general instructions for using FASTINST to install POLLING.SYS. The INF file is named SYS\POLLING.INF. Take note of the base I/O port address assigned to the device.

Start the DEVTEST.EXE program in the base directory where you installed the book samples (e.g., WDMBOOK). Select the radio button labelled "Polled input". Enter the base port address for the POLLING device and press the Initialize button:

Now open a command prompt and execute TEST.EXE from the TEST\DEBUG subdirectory. TEST will read 13 characters from the POLLING device. You supply those characters one at a time in the input window of the DEVTEST dialog. Type slowly -- POLLING.SYS looks for a character only every ½ second, so it would be very easy to "overrun" the device.

After you enter 13 characters, TEST.EXE will print them out.

### What to look for

ReadWrite.cpp contains the key routines in this sample, including PollingThreadRoutine, StartPollingThread, and StopPollingThread.