MTTTY: Multi-threaded Terminal Sample (Win32) MTTTY illustrates overlapped serial communication using multiple threads. MTTTY is a companion sample for the "Serial Communication in Win32" technical article in the Microsoft(R) Developer Network Library. MTTTY was built and tested under Microsoft Windows(TM) 95 and Microsoft Windows NT 3.51 using Microsoft Visual C/C++ version 2.0 and the combined Win32 SDK for Windows 95 and Windows NT. How it works: The program utilizes 3 threads. A main thread initializes the comm port and maintains the user interface while two working threads do all the serial communication work. A reader/status thread is created to handle port reading and to monitor status events. The thread issues an overlapped read operation and an overlapped status operation. When one of these operation completes, it is handled and information is imparted to the user. If a timeout occurs waiting for an operation to complete, background work is performed. A writer thread is created to accept output requests and send them out the comm port. The writer thread utilizes a work queue. Each output request is placed on a linked list in a private heap and a syncrhonization event is signaled to indicated new work. When the writer thread is available to do work, it will retrieve the output request and perform the output. Caution: This sample utilizes multiple threads only for the sake of simplicity and performance. A more efficient method for this program might be to have a single thread perform all i/o requests and then wait on multiple handles for each operation to complete. Creating multiple threads just for the sake of simplicity in a full blown application may not be best implementation. I chose the model for reasons specific to file transfer. I wanted reading and writing to be completely separate operations not dependant on each other in any way. KEYWORDS: MTTTY