一种改进型多线程机制在数据采集系统中的应用
2019-08-13王嘉范蟠果毛恒
王嘉 范蟠果 毛恒



摘 要:为缓解数据采集实时性要求较高和数据处理延时较大之间的矛盾,研究了LabWindows/CVI软件开发环境下的多线程机制和相关的数据保护机制。并对传统数据采集多线程机制进行改进,除了为数据采集任务创建线程外,单独为每一路数据通道创建独立的线程用以处理该通道数据。实验结果表明:改进后的多线程机制更加适合数据处理耗时较长、数据通道多、实时性要求严格的系统,能显著提高系统实时性和软件运行效率。
关键词:LabWindows/CVI;多线程;数据采集;数据通道
中图分类号:TP29 文獻标识码:A
Application of an Improved Multithreading Mechanism
in Data Acquisition System
WANG Jia?覮,FAN Pan-guo,MAO Heng
(Northwestern Polytechnical University,Xi'an,Shaanxi 710072,China)
Abstract:In order to alleviate the contradiction between high real-time requirement of data acquisition and large data processing delay,the multithreading mechanism and related data protection mechanism in LabWindows/CVI environment are studied. For the purpose of improvement,in addition to creating threads for data acquisition tasks,separate threads are created for each data channel to process the channel data. The experimental results show that the improved multi-threading mechanism is more suitable for systems with long data processing time,multiple data channels and strict real-time requirements,and can significantly improve the real-time performance of the system and the efficiency of software operation.
Key words:LabWindows/CVI;multi-threading;data acquisition;data channel
随着计算机技术和测控技术的快速发展,在工程应用中,多任务并行能力已成为衡量测控软件性能的重要标准之一。而计算机中的多线程技术特别适用于实时性强的多任务系统[1],在测控软件中运用多线程机制,可以同步并行完成多个任务,从而提高软件的运行效率和系统的响应速度。在本文中将传统多通道数据采集系统的多线程机制进行改进,有效缓解了数据采集实时性要求较高和数据处理延时较大之间的矛盾,确保了两者的同步性。
1 LabWindows/CVI多线程技术
多线程技术基于操作系统的时间片轮转调度机制,使多个任务在宏观上并行执行。在典型应用多线程的LabWindows/CVI程序中,开发者使用主线程来创建用户界面并响应其动作,而使用辅助线程来进行其它时间要求严格的操作[2],如数据采集、实时监控等,极大提高了CPU使用率和程序的运行效率。……
