From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global variable of type semaphore

Hi,

I have to do a global variable of type semaphore. How can I do it? I have a vi of global variables and I want to create  there another one of type semaphore.

Thanks,

ToNi.
0 Kudos
Message 1 of 5
(3,425 Views)
Hi again,

I need to do what I explained you because I want to share a semaphore between Vi's.

How can I share a semaphore created in one VI with others VIs?

Thanks,

ToNi.
0 Kudos
Message 2 of 5
(3,419 Views)
have you looked at the built-in semaphore example? Just search for "semaphore" in the example finder.
------------------------------------------------------------------------------------
Seriously concerned about the Labview subscription model
0 Kudos
Message 3 of 5
(3,416 Views)
Hi,

Yes, but in this example the main vi pass the reference of the semaphore to the others VI's as an input parameter  to each block but I don't want it, I want to share the reference of the semaphore create in one vi (main vi) to others VI's without passing it as an input parameter, for example, I want in the others vi's to read the reference of the semaphore create in main vi.

Thanks,

ToNi.
0 Kudos
Message 4 of 5
(3,414 Views)

You should be careful when using references as globals because you have to make sure that the reference is created before you start using it and you have to keep it in memory until you stopped using it.

I think you have 2 options - the first is to create a global by right clicking the semaphore VI, creating a control for the reference and copying and pasting that control in the global VI. The control itself is a typedef in the VI.Lib folder.

The second option is to use the built in design - use Create Semaphore in different VIs with the same name. This will give you access to the same semaphore. This means that the first VI calling the Create VI will create the semaphore. Read the help for the VI for more details.

___________________
Try to take over the world!
0 Kudos
Message 5 of 5
(3,401 Views)