From d24b7585b7ca91ad74b1289b7736c47b58322cbf Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Fri, 31 Aug 2018 21:44:28 +0900 Subject: [PATCH] uti: Make tracee pthread-detached Change-Id: I672ee18739b956980901b63e55ee3ebc192b4e56 --- executer/user/mcexec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index efba2473..bfe46ae6 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -1032,7 +1032,7 @@ struct thread_data_s { int terminate; int remote_tid; int remote_cpu; - int joined; + int joined, detached; pthread_mutex_t *lock; pthread_barrier_t *init_ready; } *thread_data; @@ -1878,7 +1878,7 @@ join_all_threads() do { live_thread = 0; for (tp = thread_data; tp; tp = tp->next) { - if (tp->joined) + if (tp->joined || tp->detached) continue; live_thread = 1; pthread_join(tp->thread_id, NULL); @@ -3245,6 +3245,12 @@ util_thread(struct thread_data_s *my_thread, unsigned long uctx_pa, int remote_t ioctl(fd, MCEXEC_UP_UTI_ATTR, &desc); } + /* Synchronize detached state with the McKernel counterpart */ + if ((rc = pthread_detach(my_thread->thread_id)) != 0) { + fprintf(stderr, "%s: pthread_detach returned %d\n", __FUNCTION__, rc); + } + my_thread->detached = 1; /* Skip join in join_all_threads() */ + if ((rc = switch_ctx(fd, MCEXEC_UP_UTIL_THREAD2, param, lctx, rctx)) < 0) { fprintf(stderr, "util_thread2: %d\n", rc);