Jump to content

Acquire Semaphore Behavior


Recommended Posts

Hello all,

I found some thing that isn't really a bug in LabVIEW but it can be annoying. I'm working with a set of code that will scan a directory of LabVIEW VIs and create documentation for each VI. To prevent race conditions and other resource issues a semaphore was created. Since the number of VIs in the directory can be quite large, the time between steps may also take a long time. So the timeout terminal on the Semaphore was wired to be a -1 since there is no way to know how long it should wait before giving up.

With this set up I found that when an error occurred the program would hang forever and it took me a little while to discover why. Apparently if an error is wired into the error in terminal of any semaphore VI it will still attempt to execute the code. I can see where this could be a good thing, like for a Release Semaphore. If an error occurred we should still try to Release the Semaphore. But with an Acquire Semaphore I would think the code would just pass the error out if there was an error in.

Here's the help on the Acquire Semaphore VI

http://zone.ni.com/reference/en-XX/help/37...uire_semaphore/

Twords the bottom is where you'll see it mentions how it will behave with an error in.

To fix my code I simply have to check to see if an error in happens before the Acquire Semaphore VI, if it does just pass the error out. In my defense I didn't write this code but if I did I probably would have done the same thing and just assumed that the Semaphore VIs behaved as a lot of code does.

Link to comment

QUOTE(hooovahh @ Dec 17 2007, 03:09 PM)

To fix my code I simply have to check to see if an error in happens before the Acquire Semaphore VI, if it does just pass the error out. In my defense I didn't write this code but if I did I probably would have done the same thing and just assumed that the Semaphore VIs behaved as a lot of code does.

The expected solution is that you would just have Release Semaphore also be outside of your error case structure so that any time Acquire Semaphore executes, Release Semaphore is also guaranteed to execute.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.