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.

Example Code

Functional Global Flags to Protect a Shared Resource in LabVIEW

Code and Documents

Attachment

Overview:

This VI exemplifies how to check which user is accessing a shared resource.
Description:

There are three actions: Release Access, Get Access, Get Status.
-Get Access: Checks to see if the resource is in use; if not, it passes the requesting user's flags. If the resource is in use, it passes the existing flags to notify which user is accessing the resource and updates the "Resource is in use" output to true.
-Release Access: Checks to see if the user requesting to release access is the last one to set the flags - if so, then an array of zeros is set; if not, then it passes the existing flags to notify which user was last granted access.
-Get Status: Passes out current flags and current in use status.
This VI could be useful for setting security access for a shared resource like a specific VI, hardware, database or library.
Requirements:

LabVIEW Base Development System.
Steps to Implement or Execute Code:
1. Open the attached VI "Functional Global Flags to Protect Shared Resource LV 2012 - NI Verified.vi".
2. Run the VI as a FGV.
Additional Information or References: Snippet 12054.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

--Michelle

National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
WG-
Member
Member
on

So this is something just like a semaphore? Can you maybe give an example of a application?

Fred_A
Member
Member
on

I have the same comment, it look nice, but I dont' understand the real finality of this VI (how it work as subVI)..