找回密码
 注册
LabVIEW+单片机学习套件全套教程资料下载[免费]LabVIEW论坛精华列表贴USB0816数据采集卡《LabVIEW宝典》
LabWindows/CVI论坛精华贴NET0816以太网数据采集卡RC0210远程设备授权系统 关闭关停锁定打开设备 户外分布式数据采集
NET1624低速高精度以太网数据采集卡WIFI0824SD无线WIFI网络数据采集卡脱机运行 SD存储 小尺寸微型 串口采集远程采集 安卓 手持移动采集 纪录仪
查看: 1357|回复: 4

关于全局变量的疑问

[复制链接]
发表于 2008-4-27 00:20:27 | 显示全部楼层 |阅读模式
关于全局变量这个东西有些地方还是不太清楚,请高人指点
全局变量在另一个vi里调用的时候会不会在内存中复制一份?
如果会复制,是不是每调用一次都要复制一份?
如果全局变量是一个队列,调用的时候会不会把整个队列的内容给复制一份?
发表于 2008-4-27 10:27:45 | 显示全部楼层
它应该只有一个内存中的位置,然后每次读的是相同的区域!如果要复制的话,它应该就读不到变化后的数据了!
回复 顶

使用道具 举报

发表于 2008-4-28 16:30:54 | 显示全部楼层
应该是不会复制的,只是读同一个位置的值··
回复 顶

使用道具 举报

发表于 2008-4-29 14:03:54 | 显示全部楼层
Avoiding Race Conditions
A race condition occurs when two or more pieces of code that execute in parallel change the value of the same shared resource. Because the outcome of the VI depends on which action executes on the shared resource first, race conditions cause unpredictability. Often, race conditions occur with the use of local and global variables or an external file, although race conditions can exist any time more than one action updates the value of the same stored data. The following block diagram shows an example of a race condition with a local variable.
请参考 http://zone.ni.com/reference/en- ... to/race_conditions/

[ 本帖最后由 labc 于 2008-4-29 14:06 编辑 ]
回复 顶

使用道具 举报

 楼主| 发表于 2008-4-29 14:55:02 | 显示全部楼层
谢谢楼上各位,如果不复制我就不用担心队列在两个程序之间通信会影响性能的问题了,至于变量之间的竞争在我的程序里影响不是太大
回复 顶

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cpubbs论坛. ( 粤ICP备09171248号 )

GMT+8, 2026-9-30 07:50 , Processed in 0.031232 second(s), 6 queries , Gzip On, File On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表