LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to ger process ID and thread ID in LV 2012

Hi,

 

The question is simple. Exactly as in the subject.

 

I've found out one old post (almost 10 years old) http://forums.ni.com/t5/LabVIEW/Get-the-process-ID-pid/m-p/148326/highlight/true#M88827 but I think maybe sometjing has changed since then.

 

Any new way of doing this?

 

K.

0 Kudos
Message 1 of 6
(2,972 Views)

K.,

 

getting the process ID is easy using the GetCurrentProcessID from the kernel32.dll.

Regarding the thread ID, i am not sure if you will get what you expect. Since LV handles its own threads, there are already a couple of those present. And it is possible, that execution of your VI changes thread over time, is even split up into different threads. So even if the process ID is "rather static" (are you sure about that at all?), the thread ID will most definetly be not.....

 

Norbert

 

PS: GetCurrentThreadID would return what you are looking for, but i doubt that the result is what you expect it to be as said above....

EDIT: If the CLFN is configured to execute in the UI thread, that ID should be rather static as well..... but if you configure it to run in any thread, above info will affect you.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 6
(2,963 Views)

Thanks,

 

For thread ID I'm expecting to see a kind of unique ID which identify the thread for a loop.

 

My application has a few loops working as producers. To identify from which loop I'm getting result I was thinking of getting the thread ID (each loop is in separete thread, isn't it?). O course I can do an 'artificial' ID but I didn't want to reinvent the wheel for the second time.

0 Kudos
Message 3 of 6
(2,957 Views)

Loop !=  Thread.

 

A loop in LV could be split up between different threads and a single thread could execute several loops (one after another using the included wait times of each loop). So thread ID is near to useless to do what you are looking for.

Most developers add an ID field in the queue element which each producer will populate for each element enqueued. The ID is usually the name of the process (string).

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 6
(2,950 Views)

OK,

 

As I thought the internal artifical ID is the simplest.

 

Where I can get more information about that a loop doesn't equal a thread? I'd need top level informtion how it is done.

0 Kudos
Message 5 of 6
(2,947 Views)

I would think that this tutorial is a good point for you to start looking. The keyword you look for is "clumping".

NI does not provide much information on the process of clumping and the distribution of clumps over threads as this is one of the essential internal mechanisms how LV works.

 

Besides: It doesn't really matter if you know much about it or not as you cannot influence it directly (e.g. using some checkboxes). The only way to effect it is to write proper code.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 6
(2,943 Views)