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

[Minios-devel] [UNIKRAFT PATCH 15/23] lib/ukschedpreempt: Introduce library skeleton


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 8 Jul 2019 11:33:44 +0300
  • Cc: felipe.huici@xxxxxxxxx, simon.kuenzer@xxxxxxxxx
  • Delivery-date: Mon, 08 Jul 2019 08:53:27 +0000
  • Ironport-phdr: 9a23:oT2ReBZqCRKoTDkueQDIaev/LSx+4OfEezUN459isYplN5qZr8u/bnLW6fgltlLVR4KTs6sC17OM9fy4EjRcqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba5sIBmsogjdqsYajZdtJ60s1hbHv3xEdvhMy2h1P1yThRH85smx/J5n7Stdvu8q+tBDX6vnYak2VKRUAzs6PW874s3rrgTDQhCU5nQASGUWkwFHDBbD4RrnQ5r+qCr6tu562CmHIc37SK0/VDq+46t3ThLjlSEKPCM7/m7KkMx9lKJVrgy8qRJxwIDaZ4OaNPRlc6/BYd8XX3ZNU9xNWyBdBI63cosBD/AGPeZdt4TwuVwOrQCiBQmtAuPk1zlGhmLu3a0nzu8sFh3J3As7H9ISsXTUqs/5NKMPUeCt0anF1inMb+hM1Tfl9YjHaQotoeuLXb9pd8fa1EohFxvdg1mNpoHpIimZ2+cNvmSB8eZsS+Cih3Qppg1pvzSiydoghpPKi48V0FzI6yt0zYgvKdGlR0N3f9ipG4ZKuS6ALYt5WMYiTnltuCY917IJp4a2fDMPyJQ73x7fbOGHc5SQ7hLjSumRJTB4iWp7eLK6nRmy8EygxvfgWcmvylpKtjdFncLWunAX0Bzf8smHSv1j8Ue9wTuDyg/e5vxeLU03lafXMYAtzqAym5YJv0nPBir2l1/3jK+SeEUk4O+o6+H/b7r6oZ+cLJN0igD4Mqg0nsy/HPw4MhUVUmeH4uSwzqXj/VDiT7lQlP02lbHVsIrGKsQDuq65HwhV354m6xa+CTem0dMYnWIeIF1YZh2HkZbmO1XVLfD8DPe/mEiskCxxy/HJILLhBI/BLn/ZkLfuZbx98VJTyBIvzdBD4JJZEr8BL+z3Wk/wrNzXEAU1Mwypw+bmFNp915gTWWSRDaCFNKPdq0SH6vgxLOmRfIUVoiryK+A55/7yin80gUQdfais3ZsQbnC0BPdmI1iHbnrqg9YOD30KsxE4TOP0lFKCVSRcaG2oU60i+zFoQL6hWILCQIGqm/mN0Tm2GrVSZ3taERacHHGucJ+LCNkWbyfHCch6jj0CHZy8U5JpgRqprxP7zfxjM/LJ0iYD84r+3p5v4LuAxlkJ6TVoApHFgCm2RGZukzZQSg==
  • Ironport-sdr: laX5CR1mLUQXoT+VdiyqSHiBAVKQf66/kzF+XlFYr2nPsIpY+1jJYzt3am2Q3VV2U9DlWTXY7n 5BxC5SXT3HNQ==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

We introduce the preemptive scheduler library. This patch contains only the 
library
skeleton and may be also used as a template for other future scheduler
implementations.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 lib/Config.uk                                |  5 ++
 lib/Makefile.uk                              |  1 +
 lib/ukschedpreempt/Config.uk                 |  5 ++
 lib/ukschedpreempt/Makefile.uk               |  6 ++
 lib/ukschedpreempt/exportsyms.uk             |  1 +
 lib/ukschedpreempt/include/uk/schedpreempt.h | 51 ++++++++++++++
 lib/ukschedpreempt/schedpreempt.c            | 71 ++++++++++++++++++++
 7 files changed, 140 insertions(+)
 create mode 100644 lib/ukschedpreempt/Config.uk
 create mode 100644 lib/ukschedpreempt/Makefile.uk
 create mode 100644 lib/ukschedpreempt/exportsyms.uk
 create mode 100644 lib/ukschedpreempt/include/uk/schedpreempt.h
 create mode 100644 lib/ukschedpreempt/schedpreempt.c

diff --git a/lib/Config.uk b/lib/Config.uk
index f61d3b1e..93d6f717 100644
--- a/lib/Config.uk
+++ b/lib/Config.uk
@@ -17,6 +17,10 @@ config HAVE_SCHED
        bool
        default n
 
+config HAVE_SCHED_PREEMPT
+       bool
+       default n
+
 config HAVE_NW_STACK
        bool
        default n
@@ -38,6 +42,7 @@ source "lib/ukalloc/Config.uk"
 source "lib/ukallocbbuddy/Config.uk"
 source "lib/uksched/Config.uk"
 source "lib/ukschedcoop/Config.uk"
+source "lib/ukschedpreempt/Config.uk"
 source "lib/fdt/Config.uk"
 source "lib/syscall_shim/Config.uk"
 source "lib/vfscore/Config.uk"
diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index b7ad6287..9ce66e64 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -16,6 +16,7 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukalloc))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocbbuddy))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uksched))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukschedcoop))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukschedpreempt))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/fdt))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/syscall_shim))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/vfscore))
diff --git a/lib/ukschedpreempt/Config.uk b/lib/ukschedpreempt/Config.uk
new file mode 100644
index 00000000..dc95d542
--- /dev/null
+++ b/lib/ukschedpreempt/Config.uk
@@ -0,0 +1,5 @@
+config LIBUKSCHEDPREEMPT
+       bool "ukschedpreempt: Preemptive scheduler"
+       default n
+       depends on LIBUKSCHED
+       select HAVE_SCHED_PREEMPT
diff --git a/lib/ukschedpreempt/Makefile.uk b/lib/ukschedpreempt/Makefile.uk
new file mode 100644
index 00000000..544e5490
--- /dev/null
+++ b/lib/ukschedpreempt/Makefile.uk
@@ -0,0 +1,6 @@
+$(eval $(call addlib_s,libukschedpreempt,$(CONFIG_LIBUKSCHEDPREEMPT)))
+
+CINCLUDES-$(CONFIG_LIBUKSCHEDPREEMPT)     += 
-I$(LIBUKSCHEDPREEMPT_BASE)/include
+CXXINCLUDES-$(CONFIG_LIBUKSCHEDPREEMPT)   += 
-I$(LIBUKSCHEDPREEMPT_BASE)/include
+
+LIBUKSCHEDPREEMPT_SRCS-y += $(LIBUKSCHEDPREEMPT_BASE)/schedpreempt.c
diff --git a/lib/ukschedpreempt/exportsyms.uk b/lib/ukschedpreempt/exportsyms.uk
new file mode 100644
index 00000000..cf856155
--- /dev/null
+++ b/lib/ukschedpreempt/exportsyms.uk
@@ -0,0 +1 @@
+uk_schedpreempt_init
diff --git a/lib/ukschedpreempt/include/uk/schedpreempt.h 
b/lib/ukschedpreempt/include/uk/schedpreempt.h
new file mode 100644
index 00000000..7b0a5e58
--- /dev/null
+++ b/lib/ukschedpreempt/include/uk/schedpreempt.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Costin Lupu <costin.lupu@xxxxxxxxx>
+ *
+ * Copyright (c) 2019, University Politehnica of Bucharest. All rights 
reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+#ifndef __UK_SCHEDPREEMPT_H__
+#define __UK_SCHEDPREEMPT_H__
+
+#include <uk/sched.h>
+#include <uk/alloc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct uk_sched *uk_schedpreempt_init(struct uk_alloc *a);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UK_SCHEDPREEMPT_H__ */
diff --git a/lib/ukschedpreempt/schedpreempt.c 
b/lib/ukschedpreempt/schedpreempt.c
new file mode 100644
index 00000000..789c34db
--- /dev/null
+++ b/lib/ukschedpreempt/schedpreempt.c
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Costin Lupu <costin.lupu@xxxxxxxxx>
+ *
+ * Copyright (c) 2019, University Politehnica of Bucharest. All rights 
reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+#include <uk/schedpreempt.h>
+
+struct schedpreempt_private {
+};
+
+struct uk_sched *uk_schedpreempt_init(struct uk_alloc *a)
+{
+       struct uk_sched *sched = NULL;
+       struct schedpreempt_private *prv = NULL;
+
+       uk_pr_info("Initializing preemptive scheduler\n");
+
+       sched = uk_sched_create(a, sizeof(struct schedpreempt_private));
+       if (sched == NULL)
+               goto out_err;
+
+       prv = sched->prv;
+
+       uk_sched_init(sched,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL);
+
+       return sched;
+
+out_err:
+       if (sched)
+               uk_free(a, sched);
+
+       return NULL;
+}
-- 
2.20.1


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