[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 15/23] lib/ukschedpreempt: Introduce library skeleton
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |