[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v3 06/12] lib/uksched: Revisit thread exiting logic
We use a list for terminated threads on all schedulers because it keeps references to those threads until wait is called for them. Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx> --- lib/uksched/include/uk/sched.h | 1 + lib/uksched/sched.c | 7 ++++--- lib/ukschedcoop/schedcoop.c | 11 +++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/uksched/include/uk/sched.h b/lib/uksched/include/uk/sched.h index 9554c6e1..e5630ed6 100644 --- a/lib/uksched/include/uk/sched.h +++ b/lib/uksched/include/uk/sched.h @@ -87,6 +87,7 @@ struct uk_sched { /* internal */ struct uk_thread idle; + struct uk_thread_list exited_threads; struct ukplat_ctx_callbacks plat_ctx_cbs; struct uk_alloc *allocator; struct uk_sched *next; diff --git a/lib/uksched/sched.c b/lib/uksched/sched.c index d7ca7f35..a0d706f5 100644 --- a/lib/uksched/sched.c +++ b/lib/uksched/sched.c @@ -122,6 +122,7 @@ struct uk_sched *uk_sched_create(struct uk_alloc *a, size_t prv_size) } sched->allocator = a; + UK_TAILQ_INIT(&sched->exited_threads); sched->prv = (void *) sched + sizeof(struct uk_sched); return sched; @@ -213,6 +214,9 @@ void uk_sched_thread_destroy(struct uk_sched *sched, struct uk_thread *thread) { UK_ASSERT(sched != NULL); UK_ASSERT(thread != NULL); + UK_ASSERT(is_exited(thread)); + + UK_TAILQ_REMOVE(&sched->exited_threads, thread, thread_list); uk_thread_fini(thread, sched->allocator); uk_pfree(sched->allocator, thread->stack, STACK_SIZE_PAGE_ORDER); uk_free(sched->allocator, thread); @@ -232,9 +236,6 @@ void uk_sched_thread_exit(void) struct uk_thread *thread; thread = uk_thread_current(); - - uk_pr_info("Thread \"%s\" exited.\n", thread->name); - UK_ASSERT(thread->sched); uk_sched_thread_remove(thread->sched, thread); UK_CRASH("Error stopping thread."); diff --git a/lib/ukschedcoop/schedcoop.c b/lib/ukschedcoop/schedcoop.c index 5091c913..2a646760 100644 --- a/lib/ukschedcoop/schedcoop.c +++ b/lib/ukschedcoop/schedcoop.c @@ -36,7 +36,6 @@ struct schedcoop_private { struct uk_thread_list thread_list; - struct uk_thread_list exited_threads; int threads_started; }; @@ -123,16 +122,13 @@ static void schedcoop_schedule(struct uk_sched *s) if (prev != next) uk_sched_thread_switch(s, prev, next); - UK_TAILQ_FOREACH_SAFE(thread, &prv->exited_threads, thread_list, tmp) { + UK_TAILQ_FOREACH_SAFE(thread, &s->exited_threads, thread_list, tmp) { if (!thread->detached) /* someone will eventually wait for it */ continue; - if (thread != prev) { - UK_TAILQ_REMOVE(&prv->exited_threads, - thread, thread_list); + if (thread != prev) uk_thread_destroy(thread); - } } } @@ -163,7 +159,7 @@ static void schedcoop_thread_remove(struct uk_sched *s, struct uk_thread *t) uk_thread_exit(t); /* Put onto exited list */ - UK_TAILQ_INSERT_HEAD(&prv->exited_threads, t, thread_list); + UK_TAILQ_INSERT_HEAD(&s->exited_threads, t, thread_list); ukplat_lcpu_restore_irqf(flags); @@ -208,7 +204,6 @@ struct uk_sched *uk_schedcoop_init(struct uk_alloc *a) ukplat_ctx_callbacks_init(&sched->plat_ctx_cbs, ukplat_ctx_sw); prv = sched->prv; - UK_TAILQ_INIT(&prv->exited_threads); UK_TAILQ_INIT(&prv->thread_list); prv->threads_started = 0; -- 2.11.0 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |