jcrooke wrote:
> Thanks for your insight, Greg. I was surprised to learn that global
> references each contain a copy of the data. This implies that each
> time data is written to a global, each copy of that global must get
> updated. The process sounds amazingly inefficient. Now I know why
> globals are taboo in LabVIEW.
Well for scalars they are ok. But never use them for arrays. The reason
this must be done so, is that LabVIEW execution is determined by dataflow
almost exclusively and that allows for multiple code sections executing
quasi-simultanous. Treating globals by reference could give you an issue
where one part of the program reads the global while another one writes
it, causing the read to read half of the old data and half of the new
data. In C you have typically sequential execution and if you happen to
create multiple threads and read a global from one thread while writing
it in another it is the programmers responsibility to protect that
resource or his program will behave erratically at best.
> I have noticed that most of the NI code for interfacing with registers
> and managing memory have a dll at the core. The function details are
> handled outside of the LabVIEW development toolbox, precompiled and
> self contained. It sounds to me that the only way to efficiently and
> effectively get control over the memory is to write the code block (in
> c or something) to manage the data the old fashioned way. It appears,
> as I have anxiously suspected, there's no substitute for knowing how
> to manage memory at the lowest level.
That is not the main problem. LabVIEW data types are a little different
than what C usually uses and it is easier to create the translation in C
than in LabVIEW. And since almost all direct hardware interfaces are
really C oriented this means that there is a DLL sooner or later. You
can't write a device driver in LabVIEW at all, as that is privileged
code executing in kernel space. Accessing a device driver from LabVIEW
although possible is quite a pain as the high level data structures used
in LabVIEW are most often completely different than the low level
interface of the device driver. So there again you need an intermediate
translation unit which is simply more convinient to write in C. And if
you don't know how to write that in C you couldn't possibly create a
direct interface in LabVIEW, but since you then know C it is easier to
do it in C then.
Not to mention that device driver interfaces are mostly undocumented and
often considered company secret. Putting the interface in a DLL hides
this interface much more effectively than trying to do everything
directly from within LabVIEW.
Rolf Kalbermatter
Rolf Kalbermatter
My Blog 
DEMO, Electronic and Mechanical Support department, room 36.LB00.390