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

[Minios-devel] [UNIKRAFT PATCH v4 09/12] lib/uksched: Revisit public scheduling functions


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Fri, 22 Mar 2019 16:16:36 +0200
  • Cc: Florian.Schmidt@xxxxxxxxx
  • Delivery-date: Fri, 22 Mar 2019 14:16:50 +0000
  • Ironport-phdr: 9a23:DcXyURWcFMTC6WUTu+kmovGIn+HV8LGtZVwlr6E/grcLSJyIuqrYbBWOt8tkgFKBZ4jH8fUM07OQ7/m4HzNZqsve+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe7x/IAiqoQnLtMQanIRuJ6YzxxDUvnZGZuNayH9yK1mOhRj8/MCw/JBi8yRUpf0s8tNLXLv5caolU7FWFSwqPG8p6sLlsxnDVhaP6WAHUmoKiBpIAhPK4w/8U5zsryb1rOt92C2dPc3rUbA5XCmp4ql3RBP0jioMKjg0+3zVhMNtlqJWuBKvqQJizYDaY4+bM/hxfq3GcN8GWWZMRNpdWjZdDo+gaYYEEuoPPfxfr4n4v1YDsxy+BRKwBOPuzD9Dm3n43bAi0+Q8DArL2xAvH9UVsHTIrdX1Mr0eUeSozKnQ0DXOdO9Z2Szn5IjQbxAuuuuAXah3ccfIz0QkCgDLjk2IpID4MD6Zy/4Bvmub4uZ6S+6jlWwqpxt/rzS328shhZTFipgWx13E7yl13og4KNOiREJmbtOoDp1dvDyAOYRsWMMtWWRotT4/yr0BpJG0YjAHyI8ixx7Dc/yHdJWI4g77WOaRPzh4gHVldaqhhxa360egy+n8WtOo31ZRtCZFisTMuWsX2xzJ7ciLUvp9/kG/1jaTzw3f9+5JLV0umafYK5Mt2KA8moQRvEjZECL6gED2g7WXdkUg9Oio8ePnYrD+q5CAMI90kR3+MqUomsClBeQ4LxAOX3WA9Ougz73v51X5QKhRgfEsiKnZt4jWJd4Hqa6hHw9VzoEj5g66Dzen1tQYnH4HLElcdB2akYfpJU/BIPTjAPe7glSsiytrx+vcMrzuHJrNKGLPkLD7fbZy80Rc0hY8zchD55JIDbEMOPL9Wkv2tNzCDx82KQq0z/z6Btph1oMeXGOPDbKFMK7Jt1+H+P4gI+2Wa4AOojryNeUltLbSiio8mFkcerLs0ZYJZXSQGvV9P17fcXfqxNAbHjQkpA07Gcftk0GDV3Z3em6vF/Y34SonCYTgCZrbW6imm/qZwS39BJoANTMOMUyFDXq9L9bMYPwLci/HesI=
  • Ironport-sdr: LITrgtgxRjdjpCMKcHdX/o9M8UVjUuUHX6EloFDfnbIRjkpAnP2S+Y2eOdGcpG7ZZww+kKZhmr zf5iVGxb4qtg==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

Currently, uk_sched_start and uk_sched_started are the only scheduler
functions (which do not contain any thread reference) that are public.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 lib/uksched/include/uk/sched.h | 18 ++++++++++++------
 lib/uksched/sched.c            |  1 +
 lib/ukschedcoop/schedcoop.c    |  5 +----
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/lib/uksched/include/uk/sched.h b/lib/uksched/include/uk/sched.h
index 3eb1f4ec..b29211f5 100644
--- a/lib/uksched/include/uk/sched.h
+++ b/lib/uksched/include/uk/sched.h
@@ -86,6 +86,7 @@ struct uk_sched {
        uk_sched_thread_get_tslice_func_t thread_get_tslice;
 
        /* internal */
+       bool threads_started;
        struct uk_thread idle;
        struct uk_thread_list exited_threads;
        struct ukplat_ctx_callbacks plat_ctx_cbs;
@@ -193,12 +194,6 @@ static inline struct uk_thread *uk_sched_get_idle(struct 
uk_sched *s)
        return &s->idle;
 }
 
-/*
- * Public scheduler functions
- */
-
-void uk_sched_start(struct uk_sched *sched) __noreturn;
-
 #define uk_sched_init(s, yield_func, \
                thread_add_func, thread_remove_func, \
                thread_set_prio_func, thread_get_prio_func, \
@@ -214,6 +209,17 @@ void uk_sched_start(struct uk_sched *sched) __noreturn;
                uk_sched_register((s)); \
        } while (0)
 
+/*
+ * Public scheduler functions
+ */
+
+void uk_sched_start(struct uk_sched *sched) __noreturn;
+
+static inline bool uk_sched_started(struct uk_sched *sched)
+{
+       return sched->threads_started;
+}
+
 
 /*
  * Internal thread scheduling functions
diff --git a/lib/uksched/sched.c b/lib/uksched/sched.c
index 5f6bc685..a6f49d67 100644
--- a/lib/uksched/sched.c
+++ b/lib/uksched/sched.c
@@ -121,6 +121,7 @@ struct uk_sched *uk_sched_create(struct uk_alloc *a, size_t 
prv_size)
                return NULL;
        }
 
+       sched->threads_started = false;
        sched->allocator = a;
        UK_TAILQ_INIT(&sched->exited_threads);
        sched->prv = (void *) sched + sizeof(struct uk_sched);
diff --git a/lib/ukschedcoop/schedcoop.c b/lib/ukschedcoop/schedcoop.c
index 559df006..fcb9ac43 100644
--- a/lib/ukschedcoop/schedcoop.c
+++ b/lib/ukschedcoop/schedcoop.c
@@ -36,7 +36,6 @@
 
 struct schedcoop_private {
        struct uk_thread_list thread_list;
-       int threads_started;
 };
 
 #ifdef SCHED_DEBUG
@@ -176,9 +175,8 @@ static void idle_thread_fn(void *unused __unused)
 {
        struct uk_thread *current = uk_thread_current();
        struct uk_sched *s = current->sched;
-       struct schedcoop_private *prv = s->prv;
 
-       prv->threads_started = 1;
+       s->threads_started = true;
        ukplat_lcpu_enable_irq();
 
        while (1) {
@@ -207,7 +205,6 @@ struct uk_sched *uk_schedcoop_init(struct uk_alloc *a)
 
        prv = sched->prv;
        UK_TAILQ_INIT(&prv->thread_list);
-       prv->threads_started = 0;
 
        uk_sched_idle_init(sched, NULL, idle_thread_fn);
 
-- 
2.11.0


_______________________________________________
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®.