We use the pthread primitives for mutexes, thread creation, and rely on
the TLS provided by gcc. Can you elaborate more on the limitations the
Android target has with respect to pthread and TLS support ?
The biggest obstacle is that gcc's __thread specifier isn't supported on Android.
Currently, the only alternative seems to be the pthread_{get,set}specific() API, see http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_setspecific.html
The difference between the approaches is that with POSIX TLS we will have to dynamically obtain a pointer to the thread local rcu_reader rather than thread local struct. (See code below)
static inline void _rcu_read_lock(void) {
unsigned long tmp;
cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */
#ifdef USE_POSIX_TLS
struct rcu_reader *rcu_reader = thread_local_rcu_reader();
tmp = rcu_reader->ctr;
if (likely(!(tmp & RCU_GP_CTR_NEST_MASK))) {
_CMM_STORE_SHARED(rcu_reader->ctr, _CMM_LOAD_SHARED(rcu_gp_ctr));
smp_mb_slave(RCU_MB_GROUP);
} else {
_CMM_STORE_SHARED(rcu_reader->ctr, tmp + RCU_GP_COUNT);
}
#else
tmp = rcu_reader.ctr;
if (likely(!(tmp & RCU_GP_CTR_NEST_MASK))) {
_CMM_STORE_SHARED(rcu_reader.ctr, _CMM_LOAD_SHARED(rcu_gp_ctr));
smp_mb_slave(RCU_MB_GROUP);
} else {
_CMM_STORE_SHARED(rcu_reader.ctr, tmp + RCU_GP_COUNT);
}
#endif
}
What worries me a bit is the macro CMM_ACCESS_ONCE (inside _CMM_STORE_SHARED) that I have yet to grok.
/Per
_______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
