Hi EPICS folks,
I have some questions regarding an EPICS client and multi-threading on WINDOWS. Let me start by
laying out the development environment.
I am developing an interface to an EPICS motor record using the CA API.
I am using base 3.14.8.2. I am compiling under Windows XP using Visual Studio
2008. I have successfully compiled all necessary components this way. I
know that there are no issues with the compiling because all of the
utilities and executables generated by the base are functional. My interface is
being generated in a GUI application for Windows XP. When I
start the program, the main process thread instantiates a class which
contains all of my EPICS related code. This class will connect to the
various PVs I require and store their chid objects for future access.
For initialization, I call these functions from the main task.
int nRet = ca_context_create(ca_enable_preemptive_callback);
m_pEPICSContext = ca_current_context();
I then go on to do other necessary steps for my program and eventually I
complete startup. Once startup has completed, there is a spawned thread
which will go to my EPICS class at a specified interval and retrieve new
data from the EPICS motors. This thread is priority
THREAD_PRIORITY_ABOVE_NORMAL, is attached
to the main task’s context using
ca_attach_context(m_pEPICSContext),
and periodically calls ca_get, then ca_pend_io to retrieve the motor data. I use
a 5 second timeout value for ca_pend_io. This normally works to successfully retrieve the motor data.
However, when I launch another thread at priority
THREAD_PRIORITY_ABOVE_NORMAL, and this thread keeps the CPU busy,
then for some reason the ca_pend_io function returns with timeout
(User specified timeout on IO operation expired). The WINDOWS O/S appears to swap CPU time between the two ABOVE_NORMAL priority threads,
But the ca_pend_io function still time outs. Is this expected behavior? Does the low level functionality in ca_pend_io run at a
low priority, so that it will timeout? Would the ca_get_callback function work better for this situation?
Thanks,
Jay Steele
Xradia Corporation