LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make function to multithreaded call ?

Hi,

how can I make a regular function to be able to work in multithreaded call?

Should I decleare the function in special way ?

Should I decleare the function private variables in special way ?

Thank's
0 Kudos
Message 1 of 5
(3,247 Views)
no special declaration required.

But two thing to not forget:

If the content of the function is using some variable declared outside the function, then you have to add the keywork "volatile" to the declaration of these variable.

Avoid declaring static variables within the functions as you may have some stange behavior with it and the cache of the CPU...

Best Regards,
Farid.
0 Kudos
Message 2 of 5
(3,247 Views)
What about calling other functions from the multithreaded function ?

e.g.

int function_x ( int a, int b )
{
.....
}

int multithreaded_f( int x, int y )
{
.....
function_x ( x, y );
.....
}

and I am calling multithreaded_f from few seperated threades.

Best regards
0 Kudos
Message 3 of 5
(3,247 Views)
Hello

If you are unsure about how to set up an application using multi-threading, check out some of the CVI examples installed, it should be in the ..\CVI\Samples\Utility\threading folder.

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 4 of 5
(3,247 Views)
Thats fine, there is no problem as long as you keep in mind my two previous points.

I am doing that in a recent program that is currently running, in which different logging function are used by different thread at the same time, and no problem...

Best Regards,
Farid.
0 Kudos
Message 5 of 5
(3,247 Views)