Skip to contentSkip to conversation

pthread_[set|get]specific()

Xenomai-help Wolfgang Grandegger 3 participants 5 messages Oct 13, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

can pthread_[set|get]specifi()c be used safely in user space real-time tasks. Or does it result in a switch to secondary mode?

Wolfgang.

#1 lore raw
Quoted 4 lines · Wolfgang Grandegger

Hello,

can pthread_[set|get]specifi()c be used safely in user space real-time tasks. Or does it result in a switch to secondary mode?

I would expect pthread_getspecific to be safe on all platforms though (and actually, I think the fast mutexes implementation relies on that).

I would say it should be always safe or always non-safe. So, you may run a test with T_WARNSW (or XNTRAPSW) and you will know whether the implementation on your platform is safe.

pthread_setspecific is another story, maybe it can trigger a re-allocation?

Signature · 1 line
                                                 Gilles.
#2 lore raw
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Wolfgang Grandegger

Hello,

can pthread_[set|get]specifi()c be used safely in user space real-time tasks. Or does it result in a switch to secondary mode?

Quoted 8 lines

I would expect pthread_getspecific to be safe on all platforms though (and actually, I think the fast mutexes implementation relies on that).

I would say it should be always safe or always non-safe. So, you may run a test with T_WARNSW (or XNTRAPSW) and you will know whether the implementation on your platform is safe.

pthread_setspecific is another story, maybe it can trigger a re-allocation?

In fact, I only need pthread_getspecific in the real-time context. Hm, is it really fast? Maybe scanning my private phtread ids is faster.

Thanks.

Wolfgang.

#3 lore raw
Quoted 9 lines · Wolfgang Grandegger
Quoted 8 lines · Gilles Chanteperdrix
Quoted 4 lines · Wolfgang Grandegger

Hello,

can pthread_[set|get]specifi()c be used safely in user space real-time tasks. Or does it result in a switch to secondary mode?

I would expect pthread_getspecific to be safe on all platforms though (and actually, I think the fast mutexes implementation relies on that).

Quoted 8 lines
Quoted 5 lines

I would say it should be always safe or always non-safe. So, you may run a test with T_WARNSW (or XNTRAPSW) and you will know whether the implementation on your platform is safe.

pthread_setspecific is another story, maybe it can trigger a re-allocation?

In fact, I only need pthread_getspecific in the real-time context. Hm, is it really fast? Maybe scanning my private phtread ids is faster.

Yes it is supposed to be a pointer dereferencement, faster than a hash or list lookup.

Signature · 1 line
                                                 Gilles.
#4 lore raw
In reply to Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Wolfgang Grandegger

Hello,

can pthread_[set|get]specifi()c be used safely in user space real-time tasks. Or does it result in a switch to secondary mode?

Quoted 9 lines

I would expect pthread_getspecific to be safe on all platforms though (and actually, I think the fast mutexes implementation relies on that).

I would say it should be always safe or always non-safe. So, you may run a test with T_WARNSW (or XNTRAPSW) and you will know whether the implementation on your platform is safe.

pthread_setspecific is another story, maybe it can trigger a re-allocation?

It does call calloc() when two-level indexing is needed to register new keys. This said, this will only happen when more than 32 keys are created. Ok, it's fragile...

Signature · 1 line
Philippe.