All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Canonical way to differentiate between NPTL / Cobalt threads
@ 2018-03-28 14:00 Julien Blanc
  2018-03-28 14:16 ` Philippe Gerum
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Blanc @ 2018-03-28 14:00 UTC (permalink / raw)
  To: Xenomai@xenomai.org

We're using a mix of regular NPTL posix threads and RT cobalt threads
in our application, using XDDP communication between them.

In a few places, we need to identify the calling context, ie, whether
we're being called from a cobalt RT thread or from a regular NPTL
thread, and act accordingly.

My understanding is that calling pthread_getschedparam and checking
that the returned policy is SCHED_FIFO does the job.

* is it correct ? Or are they some corner cases not covered by this
test ?
* is it the canonical way, or is there another one ? (maybe cheaper -
since this call will do two calls in case of a posix thread, there must
be a cheaper way to detect the running context).

Regards,

Julien




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xenomai] Canonical way to differentiate between NPTL / Cobalt threads
  2018-03-28 14:00 [Xenomai] Canonical way to differentiate between NPTL / Cobalt threads Julien Blanc
@ 2018-03-28 14:16 ` Philippe Gerum
  2018-03-28 15:00   ` Julien Blanc
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Gerum @ 2018-03-28 14:16 UTC (permalink / raw)
  To: Julien Blanc, Xenomai@xenomai.org

On 03/28/2018 04:00 PM, Julien Blanc wrote:
> We're using a mix of regular NPTL posix threads and RT cobalt threads
> in our application, using XDDP communication between them.
> 
> In a few places, we need to identify the calling context, ie, whether
> we're being called from a cobalt RT thread or from a regular NPTL
> thread, and act accordingly.
> 
> My understanding is that calling pthread_getschedparam and checking
> that the returned policy is SCHED_FIFO does the job.
> 
> * is it correct ? Or are they some corner cases not covered by this
> test ?

A regular pthread undergoing the SCHED_FIFO policy would also match this
test, so this would work as long as SCHED_FIFO is exclusively used for
Cobalt threads.

> * is it the canonical way, or is there another one ? (maybe cheaper -
> since this call will do two calls in case of a posix thread, there must
> be a cheaper way to detect the running context).
> 
cobalt_thread_pid(pthread_t) from the internal support library would do
the job. A successful call would denote a cobalt thread, -ESRCH would
denote a regular (or invalid) pthread.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xenomai] Canonical way to differentiate between NPTL / Cobalt threads
  2018-03-28 14:16 ` Philippe Gerum
@ 2018-03-28 15:00   ` Julien Blanc
  0 siblings, 0 replies; 3+ messages in thread
From: Julien Blanc @ 2018-03-28 15:00 UTC (permalink / raw)
  To: Philippe Gerum, Xenomai@xenomai.org

Le mercredi 28 mars 2018 à 16:16 +0200, Philippe Gerum a écrit :
> 
> cobalt_thread_pid(pthread_t) from the internal support library would
> do
> the job. A successful call would denote a cobalt thread, -ESRCH would
> denote a regular (or invalid) pthread.

Seems to work perfectly, thanks.

Regards,

Julien


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-28 15:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 14:00 [Xenomai] Canonical way to differentiate between NPTL / Cobalt threads Julien Blanc
2018-03-28 14:16 ` Philippe Gerum
2018-03-28 15:00   ` Julien Blanc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.