[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v3 04/12] lib/uksched: Introduce detached flag for threads





On 3/10/19 9:09 PM, Costin Lupu wrote:
By the default, detached flag is set on false meaning that one has to
wait for the thread in order to free its resources after completion.
Detached threads should not be waited on. If the flag is true then the
thread resources will be freed by the system.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>

Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>

---
  lib/uksched/exportsyms.uk       |  3 ++-
  lib/uksched/include/uk/sched.h  |  2 ++
  lib/uksched/include/uk/thread.h |  2 ++
  lib/uksched/thread.c            | 10 ++++++++++
  4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/uksched/exportsyms.uk b/lib/uksched/exportsyms.uk
index df0bb4db..334c652f 100644
--- a/lib/uksched/exportsyms.uk
+++ b/lib/uksched/exportsyms.uk
@@ -11,6 +11,7 @@ uk_sched_thread_sleep
  uk_sched_thread_exit
  uk_thread_init
  uk_thread_fini
+uk_thread_detach
  uk_thread_set_prio
  uk_thread_get_prio
  uk_thread_set_timeslice
@@ -25,4 +26,4 @@ uk_thread_attr_get_detachstate
  uk_thread_attr_set_prio
  uk_thread_attr_get_prio
  uk_thread_attr_set_timeslice
-uk_thread_attr_get_timeslice
\ No newline at end of file
+uk_thread_attr_get_timeslice
diff --git a/lib/uksched/include/uk/sched.h b/lib/uksched/include/uk/sched.h
index 5f2d308f..9554c6e1 100644
--- a/lib/uksched/include/uk/sched.h
+++ b/lib/uksched/include/uk/sched.h
@@ -111,6 +111,8 @@ static inline void uk_sched_thread_add(struct uk_sched *s,
  {
        UK_ASSERT(s);
        UK_ASSERT(t);
+       if (attr)
+               t->detached = attr->detached;
        t->sched = s;
        s->thread_add(s, t, attr);
  }
diff --git a/lib/uksched/include/uk/thread.h b/lib/uksched/include/uk/thread.h
index 5ff2dd65..5f3c2501 100644
--- a/lib/uksched/include/uk/thread.h
+++ b/lib/uksched/include/uk/thread.h
@@ -29,6 +29,7 @@
  #define __UK_THREAD_H__
#include <stdint.h>
+#include <stdbool.h>
  #ifdef CONFIG_HAVE_LIBC
  #include <sys/reent.h>
  #endif
@@ -52,6 +53,7 @@ struct uk_thread {
        UK_TAILQ_ENTRY(struct uk_thread) thread_list;
        uint32_t flags;
        __snsec wakeup_time;
+       bool detached;
        struct uk_sched *sched;
  #ifdef CONFIG_HAVE_LIBC
        struct _reent reent;
diff --git a/lib/uksched/thread.c b/lib/uksched/thread.c
index 9d065526..aeeaff17 100644
--- a/lib/uksched/thread.c
+++ b/lib/uksched/thread.c
@@ -86,6 +86,7 @@ int uk_thread_init(struct uk_thread *thread,
        /* Not runnable, not exited, not sleeping */
        thread->flags = 0;
        thread->wakeup_time = 0LL;
+       thread->detached = false;
#ifdef CONFIG_HAVE_LIBC
        //TODO _REENT_INIT_PTR(&thread->reent);
@@ -130,6 +131,15 @@ void uk_thread_wake(struct uk_thread *thread)
        set_runnable(thread);
  }
+int uk_thread_detach(struct uk_thread *thread)
+{
+       UK_ASSERT(thread);
+
+       thread->detached = true;
+
+       return 0;
+}
+
  int uk_thread_set_prio(struct uk_thread *thread, prio_t prio)
  {
        if (!thread)


--
Dr. Florian Schmidt
フローリアン・シュミット
Research Scientist,
Systems and Machine Learning Group
NEC Laboratories Europe
Kurfürsten-Anlage 36, D-69115 Heidelberg
Tel.     +49 (0)6221 4342-265
Fax:     +49 (0)6221 4342-155
e-mail:  florian.schmidt@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.