摘要
一种基于多线程的串口通信程序,导航计算机为每个串口创建一个数据接收线程,监视串口的状态,看有无数据到达,进行数据接收。而主线程则专心进行导航解算,输出导航数据至显示计算机。操作系统将CPU时间划分成许多时间片段,并按一定的优先级将时间片段分配给各个线程,线程只有在分配的时间片内才有对CPU的控制权,从而实现微观上轮次执行,宏观上并发运行的多任务机制。
Introduce a programming schema of multi-serial communication based on multi-thread technology. The navigation computer creates a sub-thread for each serial port; the main-thread concentrates on navigation calculation and output data to the display computer, while the sub-threads watch serial ports and store the data when received. Operation system divides CPU time into many segments of time, allocates a small unit of CPU time to one thread according to the priority of thread. Only thread is time-sliced, thread gets the control of CPU, thus achieving the multi-tasking mechanism of turn execution on microscopic and concurrent execution on macroscopic.
出处
《兵工自动化》
2009年第1期92-93,96,共3页
Ordnance Industry Automation
关键词
串口通信
组合导航
多线程
同步
Serial communication
Integrated navigation system
Multi-thread
Synchronization