10-04-2007 03:49 PM
Hi
I'm working on a multithreaded application. All threads will execute the same
function which calls couple of subroutines. How do I configure the program so
that each thread uses its own copy of those subroutines?
10-04-2007 04:36 PM
Calling a function from different threads usually does not require (the OS) to load the code more than once into memory. How code executes is controlled by the operating system, too.
Usually your data will mess up when it uses global variables in multiple threads.
As long as you use (non-static) local variables in your function, each thread/function creates an individual set of locals.
If the subroutines are not thread-safe (e.g. writing to global variables), there is only a small chance that your code will run as expected ...
Note:
You must be careful when dealing with shared resources in your functions/subroutines.
So: There is no chance to simply say "use an own copy of the subroutines". Please let me know Why do you think that you'd need a setting like this?
Regards, Guenter
Finally: The NI Developer Zone and this forum contain lots of articles dealing with multi-threading.
10-05-2007
07:56 AM
- last edited on
10-03-2025
09:22 AM
by
Content Cleaner
I agree with Guenter's post. To get you started with the tutorials he mentioned at the end, I have posted a link below:
Multithreading in LabWindows/CVI
Regards,