04-19-2013 05:28 AM
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.
04-19-2013 06:39 AM - edited 04-19-2013 06:41 AM
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.
04-19-2013 07:04 AM
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.
04-19-2013 07:53 AM
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
04-19-2013 08:11 AM
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.
04-19-2013 08:29 AM
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