LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is CallCtrlCallback atomic

Is CallCtrlCallback atomic in a multithreaded environment ??

I have an asynchronous timer created by NewAsyncTimer. This timer calls a UI callback using CallCtrlCallback.

I have a couple of questions :

    1) I assume that the timer runs complete asynchronously from the UI callbacks. Is this correct ?

    2) If it is correct - Does LabWindows synchronize calls into UI callbacks such that a callback must complete before another
        thread can enter the callback or can multiple timers / threads enter the same callback concurrently ?

    3) If LabWindows allows concurrent execution what is the best way to manually control access ?

Thanks !

John G
0 Kudos
Message 1 of 2
(3,006 Views)
Hello John.
 
Since CallCtrlCallback is a toolbox function, you can see its implementation by looking for it in toolslib\toolbox\toolbox.c under your CVI installation directory.
 
The answer is that no, that function is not atomic. That means that other threads can run, and can call other UI library functions, while one thread is calling CallCtrlCallback.
 
Since you are calling that function from an async timer callback, then that call is already taking place in a thread other than the thread that owns your UI panels. That means that the CallCtrlCallback thread is not the same thread that normally calls those UI callbacks, and so multiple threads can end up calling your callbacks at the same time.
 
If you'd like to restrict access so that only one thread at a time can call the callback, then one of the ways of doing that is to use in the callback the locking functions of the Utility Library (CmtNewLock / CmtGetLock / CmtReleaseLock / CmtDiscardLock)
 
Luis
0 Kudos
Message 2 of 2
(2,998 Views)