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: 

How to obtain a semaphore by name in a packed library ?

We have the following situation:

  • a packed library has some VIs which try to obtain an existing semaphore by name, e.g. "my_semaphore"
    (afaik the semaphore VIs are using LV queues in the back)
  • A main application creates the semaphore with name "my semaphore" before calling any of the plib VIs

This does not work out as the Obtain Semaphore VI throws an error that it cannot find a semaphore with name "my_semaphore".

If all VIs reside in one project (so no packed lib) everything works as it should.

 

Is this a bug ?

Or is the semaphore (=queue) naming somehow subject to name mangling due to the packed libraries name spacing ? If yes is there some kind of scope operator to obtain the semaphore anyway ?

 

Thx & br
Martin

0 Kudos
Message 1 of 3
(2,486 Views)

Hi Martin,

 

I was able to reproduce the behavior you described. The Problem seems to be the data type passed to the Obtain Queue.vi (inside Obtain Semaphore.vi). I attached my test project (LV2012 SP1), if you want to take a look. I receive error 1094, when I pass the datatype to the queue, you too?

 

It seems to be a bug, but I'm not absolutely. It also could be expected behavior. I will investigate this further and create a CAR (Corrective Action Request) if this is definitely is a bug.

 

I'll keep you up to date.

 

Kind regards,

Heinz

 

0 Kudos
Message 2 of 3
(2,422 Views)

Hi Martin,

 

a colleague of mine discussed this topic:

 

It appears that packed libraries don't create their own application instance. What they do is create copies of any dependices and build them into the library. This is problematic when a VI within a project library uses things like type definitions that are not owned by the project library. That's because when it is built into a packed library it creates its own instance of the type definition and includes it in the build as a dependency. I'm thinking that things like Type Defined Controls have a unique identifier that prevent identical looking instances from actually being identical, hence the error that says we are using different data types when trying to obtain a reference to a named queue.

 

One workaround is to duplicate the semaphore VIs from vi.lib and include them in the packed library, then use the semaphore VIs from the packed library everywhere you need to use semaphore functionality.

 

I hope this helps you.

 

Kind regards

Heinz

 

 

0 Kudos
Message 3 of 3
(2,376 Views)