* [Xenomai-core] [RFC] rt_task_join?
@ 2005-12-07 18:27 Jan Kiszka
2005-12-07 18:44 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2005-12-07 18:27 UTC (permalink / raw)
To: xenomai-core
[-- Attachment #1: Type: text/plain, Size: 994 bytes --]
Hi all,
we ran into some issue where we have to wait on the termination of a
native real-time userspace thread during cleanup. This can be done in a
custom way of course, either via some polling on a flag or by blocking
on a standard posix semaphore that are signalled by the terminating
real-time thread. But maybe it is more useful to have a generic function
available with the native skin.
The problem is now that the pthreads underneath the real-time threads
are created with PTHREAD_CREATE_DETACHED. Changing this also changes the
semantic of other rt_task_xxx functions as posix then requires the
creator to call pthread_join (i.e. a new rt_task_join) in any case. A
better option might be to introduce a new mode bit T_JOINABLE to decide
if the related pthread should be created detached or not. Default would
remain PTHREAD_CREATE_DETACHED, if rt_task_join is to be used,
T_JOINABLE could be passed to rt_task_create.
What do you think, worth the effort?
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-core] [RFC] rt_task_join?
2005-12-07 18:27 [Xenomai-core] [RFC] rt_task_join? Jan Kiszka
@ 2005-12-07 18:44 ` Jan Kiszka
2005-12-09 16:20 ` Philippe Gerum
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2005-12-07 18:44 UTC (permalink / raw)
To: xenomai-core
[-- Attachment #1: Type: text/plain, Size: 1153 bytes --]
Jan Kiszka wrote:
> Hi all,
>
> we ran into some issue where we have to wait on the termination of a
> native real-time userspace thread during cleanup. This can be done in a
> custom way of course, either via some polling on a flag or by blocking
> on a standard posix semaphore that are signalled by the terminating
> real-time thread. But maybe it is more useful to have a generic function
> available with the native skin.
>
> The problem is now that the pthreads underneath the real-time threads
> are created with PTHREAD_CREATE_DETACHED. Changing this also changes the
> semantic of other rt_task_xxx functions as posix then requires the
> creator to call pthread_join (i.e. a new rt_task_join) in any case. A
> better option might be to introduce a new mode bit T_JOINABLE to decide
> if the related pthread should be created detached or not. Default would
> remain PTHREAD_CREATE_DETACHED, if rt_task_join is to be used,
> T_JOINABLE could be passed to rt_task_create.
>
> What do you think, worth the effort?
>
Actually, the effort could be as simple as this (+ some docs) - as long
as I'm not overseeing some side effect right now.
Jan
[-- Attachment #2: rt_task_join.rfc --]
[-- Type: text/plain, Size: 2066 bytes --]
Index: include/native/task.h
===================================================================
--- include/native/task.h (revision 245)
+++ include/native/task.h (working copy)
@@ -35,18 +35,19 @@
#define T_CPUMASK 0xff000000
/* Status/mode flags. */
-#define T_BLOCKED XNPEND
-#define T_DELAYED XNDELAY
-#define T_READY XNREADY
-#define T_DORMANT XNDORMANT
-#define T_STARTED XNSTARTED
-#define T_BOOST XNBOOST
-#define T_LOCK XNLOCK
-#define T_RRB XNRRB
-#define T_NOSIG XNASDI
-#define T_SHIELD XNSHIELD
-#define T_WARNSW XNTRAPSW
-#define T_PRIMARY XNTHREAD_SPARE0
+#define T_BLOCKED XNPEND
+#define T_DELAYED XNDELAY
+#define T_READY XNREADY
+#define T_DORMANT XNDORMANT
+#define T_STARTED XNSTARTED
+#define T_BOOST XNBOOST
+#define T_LOCK XNLOCK
+#define T_RRB XNRRB
+#define T_NOSIG XNASDI
+#define T_SHIELD XNSHIELD
+#define T_WARNSW XNTRAPSW
+#define T_PRIMARY XNTHREAD_SPARE0
+#define T_JOINABLE XNTHREAD_SPARE1
/* Task hook types. */
#define T_HOOK_START XNHOOK_THREAD_START
@@ -268,6 +269,8 @@
int rt_task_slice(RT_TASK *task,
RTIME quantum);
+int rt_task_join(RT_TASK *task);
+
#ifdef CONFIG_XENO_OPT_NATIVE_MPS
ssize_t rt_task_send(RT_TASK *task,
Index: src/skins/native/task.c
===================================================================
--- src/skins/native/task.c (revision 245)
+++ src/skins/native/task.c (working copy)
@@ -127,7 +127,8 @@
stksize = PTHREAD_STACK_MIN;
pthread_attr_setstacksize(&thattr,stksize);
- pthread_attr_setdetachstate(&thattr,PTHREAD_CREATE_DETACHED);
+ if (!(mode & T_JOINABLE))
+ pthread_attr_setdetachstate(&thattr,PTHREAD_CREATE_DETACHED);
pthread_attr_setschedpolicy(&thattr,SCHED_FIFO);
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
pthread_attr_setschedparam(&thattr,¶m);
@@ -331,6 +332,11 @@
&quantum);
}
+int rt_task_join (RT_TASK *task)
+{
+ return -pthread_join((pthread_t)task->opaque2, NULL);
+}
+
#ifdef CONFIG_XENO_OPT_NATIVE_MPS
ssize_t rt_task_send (RT_TASK *task,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-core] [RFC] rt_task_join?
2005-12-07 18:44 ` Jan Kiszka
@ 2005-12-09 16:20 ` Philippe Gerum
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Gerum @ 2005-12-09 16:20 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
Jan Kiszka wrote:
> Jan Kiszka wrote:
>
>>Hi all,
>>
>>we ran into some issue where we have to wait on the termination of a
>>native real-time userspace thread during cleanup. This can be done in a
>>custom way of course, either via some polling on a flag or by blocking
>>on a standard posix semaphore that are signalled by the terminating
>>real-time thread. But maybe it is more useful to have a generic function
>>available with the native skin.
>>
>>The problem is now that the pthreads underneath the real-time threads
>>are created with PTHREAD_CREATE_DETACHED. Changing this also changes the
>>semantic of other rt_task_xxx functions as posix then requires the
>>creator to call pthread_join (i.e. a new rt_task_join) in any case. A
>>better option might be to introduce a new mode bit T_JOINABLE to decide
>>if the related pthread should be created detached or not. Default would
>>remain PTHREAD_CREATE_DETACHED, if rt_task_join is to be used,
>>T_JOINABLE could be passed to rt_task_create.
>>
>>What do you think, worth the effort?
>>
>
>
> Actually, the effort could be as simple as this (+ some docs) - as long
> as I'm not overseeing some side effect right now.
>
Looks ok.
>
>
> ------------------------------------------------------------------------
>
> Index: include/native/task.h
> ===================================================================
> --- include/native/task.h (revision 245)
> +++ include/native/task.h (working copy)
> @@ -35,18 +35,19 @@
> #define T_CPUMASK 0xff000000
>
> /* Status/mode flags. */
> -#define T_BLOCKED XNPEND
> -#define T_DELAYED XNDELAY
> -#define T_READY XNREADY
> -#define T_DORMANT XNDORMANT
> -#define T_STARTED XNSTARTED
> -#define T_BOOST XNBOOST
> -#define T_LOCK XNLOCK
> -#define T_RRB XNRRB
> -#define T_NOSIG XNASDI
> -#define T_SHIELD XNSHIELD
> -#define T_WARNSW XNTRAPSW
> -#define T_PRIMARY XNTHREAD_SPARE0
> +#define T_BLOCKED XNPEND
> +#define T_DELAYED XNDELAY
> +#define T_READY XNREADY
> +#define T_DORMANT XNDORMANT
> +#define T_STARTED XNSTARTED
> +#define T_BOOST XNBOOST
> +#define T_LOCK XNLOCK
> +#define T_RRB XNRRB
> +#define T_NOSIG XNASDI
> +#define T_SHIELD XNSHIELD
> +#define T_WARNSW XNTRAPSW
> +#define T_PRIMARY XNTHREAD_SPARE0
> +#define T_JOINABLE XNTHREAD_SPARE1
>
> /* Task hook types. */
> #define T_HOOK_START XNHOOK_THREAD_START
> @@ -268,6 +269,8 @@
> int rt_task_slice(RT_TASK *task,
> RTIME quantum);
>
> +int rt_task_join(RT_TASK *task);
> +
Should move to the user-space section of the header file (i.e. !(KERNEL
|| XENO_SIM))
> #ifdef CONFIG_XENO_OPT_NATIVE_MPS
>
> ssize_t rt_task_send(RT_TASK *task,
> Index: src/skins/native/task.c
> ===================================================================
> --- src/skins/native/task.c (revision 245)
> +++ src/skins/native/task.c (working copy)
> @@ -127,7 +127,8 @@
> stksize = PTHREAD_STACK_MIN;
>
> pthread_attr_setstacksize(&thattr,stksize);
> - pthread_attr_setdetachstate(&thattr,PTHREAD_CREATE_DETACHED);
> + if (!(mode & T_JOINABLE))
> + pthread_attr_setdetachstate(&thattr,PTHREAD_CREATE_DETACHED);
> pthread_attr_setschedpolicy(&thattr,SCHED_FIFO);
> param.sched_priority = sched_get_priority_max(SCHED_FIFO);
> pthread_attr_setschedparam(&thattr,¶m);
> @@ -331,6 +332,11 @@
> &quantum);
> }
>
> +int rt_task_join (RT_TASK *task)
> +{
> + return -pthread_join((pthread_t)task->opaque2, NULL);
> +}
> +
> #ifdef CONFIG_XENO_OPT_NATIVE_MPS
>
> ssize_t rt_task_send (RT_TASK *task,
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Xenomai-core mailing list
> Xenomai-core@domain.hid
> https://mail.gna.org/listinfo/xenomai-core
--
Philippe.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-12-09 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-07 18:27 [Xenomai-core] [RFC] rt_task_join? Jan Kiszka
2005-12-07 18:44 ` Jan Kiszka
2005-12-09 16:20 ` Philippe Gerum
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.