> So should I prepare pointer (pSca_client_context) in basic thread
> and then auxiliary thread uses it?
Yes, if the auxiliary thread wishes to use this same context it must call
the ca_attach_context () function. Here is the relevant section from the CA
reference manual.
CA Client Contexts and Application Specific Auxiliary Threads
It may be necessary for several CA client side tools running in the same
address space (process) to be independent of each other. For example, the
database CA links and the sequencer are designed to not use the same CA
client library threads, network circuits, and data structures. Each thread
that calls ca_context_create() for the first time either directly, or
implicitly when calling a CA routine for the first time, creates a CA client
library context. A CA client library context contains all of the threads,
network circuits, and data structures required to connect and communicate
with the channels that a CA client application has created. The priority of
auxiliary threads spawned by the CA client library are at fixed offsets from
the priority of the thread that called ca_context_create(). An application
specific auxiliary thread can join a CA context by calling
ca_attach_context() using the CA context identifier that was returned from
ca_current_context() when it was called by the thread that called
ca_context_create(). A CA client library context can be shut down and
cleaned up, after destroying any channels or application specific threads
that are attached to it, by calling ca_context_destroy().
> Second question.
> I open channel to PV in basic thread and have chid chidChannelToPV. I
> can use it in auxiliary thread too. Am I right?
Yes, if the auxiliary thread first calls ca_attach_context() specifying the
context that the channel was created within.
Jeff
> -----Original Message-----
> From: Liyu, Andrei [mailto:[email protected]]
> Sent: Tuesday, March 30, 2004 10:05 AM
> To: [email protected]
> Subject: CA client: Where should ca_current_context() be used?
>
> Hi,
>
> I try to do simple client with couple thread.
>
> ============================
> static void vFThreadFunction(){
> printf("Thread start\n");
> struct ca_client_context * pSca_client_context;
> pSca_client_context = ca_current_context();//*************
> SECOND PLACE
> if( pSca_client_context == NULL){
> printf("No CA context.\n");
> return;
> }
> }
>
> main(){
> printf( "Initialize CA\n");
> iStatus = ca_context_create( ca_enable_preemptive_callback);
> if( iStatus != ECA_NORMAL) printf( "%s\n", ca_message( iStatus)
> );
>
> struct ca_client_context * pSca_client_context;
> pSca_client_context = ca_current_context();//************* FIRST
> PLACE
>
> aServerThreadId = epicsThreadCreate( "Auxualury thread",
> epicsThreadPriorityMedium,
> epicsThreadStackMedium, ( EPICSTHREADFUNC)
> vFThreadFunction, NULL);
> if( aServerThreadId == 0) printf( "Thread couldn't start.\n");
> epicsThreadSleep( 10);
>
> .....
> ====================================
> In first place pSca_client_context != NULL.
> In second place pSca_client_context = NULL.
>
> So should I prepare pointer (pSca_client_context) in basic thread
> and then auxiliary thread uses it?
>
> Second question.
> I open channel to PV in basic thread and have chid chidChannelToPV. I
> can use it in auxiliary thread too. Am I right?
>
> Thanks, Andrei.
- References:
- CA client: Where should ca_current_context() be used? Liyu, Andrei
- Navigate by Date:
- Prev:
CA client: Where should ca_current_context() be used? Liyu, Andrei
- Next:
Re: ezcaIDL ELF class error Ben-chin K. Cha
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
<2004>
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
CA client: Where should ca_current_context() be used? Liyu, Andrei
- Next:
JCA2.1.2 has been released. Eric Boucher
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
<2004>
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|