Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Using External Code in LabVIEW.pdf
Скачиваний:
49
Добавлен:
29.05.2015
Размер:
1.85 Mб
Скачать

Chapter 3

CINs

Using C Code that is Thread Safe

The CINProperties function only labels your CIN as being safe to run from multiple threads. Whether the CIN is actually thread-safe depends entirely upon what C code has been written. For information about what makes C code safe or unsafe to be run from multiple threads simultaneously, please consult C programming documentation. The following list presents basic answers to the question, Is my CIN code thread safe?

The CIN code is thread safe when it stores no unprotected global data (for example, no global variables, no files on disk, and so on); does not access any hardware (in other words, does not contain register-level programming); and makes no calls to any functions, shared libraries, or drivers that are not thread safe.

The CIN code is thread safe when it uses semaphores or mutexes to protect access to global resources.

The CIN call is thread safe when only one non-reentrant VI calls the CIN; and the code accesses no global resources through CIN

housekeeping routines, such as, CINInit, CINAbort, CINDispose, and others.

Creating a CIN

In general, to create a CIN, describe in LabVIEW the data you want to pass to the CIN. Then, write the code for the CIN using one of the supported programming languages. After you compile the code, run

a utility that puts the compiled code into a format LabVIEW can use. Then, instruct LabVIEW to load the CIN.

If you run the VI at this point and the block diagram needs to execute the CIN, LabVIEW calls the CIN object code and passes any data wired to the CIN. If you save the VI after loading the code, LabVIEW saves the CIN object code along with the VI so LabVIEW no longer needs the original code to execute the CIN. You can update your CIN object code with new versions at any time.

The examples directory contains a CINs directory that includes all of the examples given in this manual. The names of the directories in CINs correspond to the CIN name in the examples.

To create a CIN, complete the following steps.

© National Instruments Corporation

3-3

Using External Code in LabVIEW

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]