From: Chris Johns <chr...@rtems.org> - Do not start threads detached --- cpukit/include/rtems/thread.hpp | 4 ++++ cpukit/librtemscxx/thread.cpp | 22 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/cpukit/include/rtems/thread.hpp b/cpukit/include/rtems/thread.hpp index e90e664dfa..2c4899dc0b 100644 --- a/cpukit/include/rtems/thread.hpp +++ b/cpukit/include/rtems/thread.hpp @@ -321,6 +321,10 @@ namespace rtems bool joinable() const noexcept; + void join() noexcept; + + void detach() noexcept; + /* * Constrain use. These are not available. */ diff --git a/cpukit/librtemscxx/thread.cpp b/cpukit/librtemscxx/thread.cpp index 11bf3df230..ae13201bd4 100644 --- a/cpukit/librtemscxx/thread.cpp +++ b/cpukit/librtemscxx/thread.cpp @@ -346,6 +346,24 @@ namespace rtems return !(id_ == id()); } + void + thread::join() noexcept + { + if (!joinable()) + system_error_check (ENOMEM, "join"); + system_error_check (::pthread_join (id_.id_, nullptr), "join"); + id_ = id(); + } + + void + thread::detach() noexcept + { + if (!joinable()) + system_error_check (EINVAL, "detach"); + system_error_check (::pthread_detach (id_.id_), "detach"); + id_ = id(); + } + thread::state_base::~state_base () = default; void @@ -358,10 +376,6 @@ namespace rtems system_error_check (::pthread_attr_init (&pattr), "attribute init"); - system_error_check (::pthread_attr_setdetachstate (&pattr, - PTHREAD_CREATE_DETACHED), - "set detached state"); - struct sched_param param; param.sched_priority = attr.get_priority (); system_error_check (::pthread_attr_setschedparam (&pattr, ¶m), -- 2.24.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel