From 55bb9159aa8c7f88a7abb6a6ecc772e8f4e51c41 Mon Sep 17 00:00:00 2001 From: Philippe Gerum Date: Wed, 22 Apr 2020 11:11:39 +0200 Subject: [PATCH] lib/sched: add evl_yield() for manual round-robin An equivalent of sched_yield(). Signed-off-by: Philippe Gerum --- include/evl/evl.h | 2 +- include/evl/sched.h | 2 ++ lib/sched.c | 9 +++++++++ tests/compile-tests/sched.cc | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/evl/evl.h b/include/evl/evl.h index 116049c..160e5b4 100644 --- a/include/evl/evl.h +++ b/include/evl/evl.h @@ -20,7 +20,7 @@ #include #include -#define __EVL__ 12 /* API version */ +#define __EVL__ 13 /* API version */ #define EVL_ABI_PREREQ 21 diff --git a/include/evl/sched.h b/include/evl/sched.h index 76c4559..448c001 100644 --- a/include/evl/sched.h +++ b/include/evl/sched.h @@ -26,6 +26,8 @@ int evl_control_sched(int policy, int evl_get_cpustate(int cpu, int *state_r); +int evl_yield(void); + #ifdef __cplusplus } #endif diff --git a/lib/sched.c b/lib/sched.c index f2ffd22..7f0ec6a 100644 --- a/lib/sched.c +++ b/lib/sched.c @@ -71,3 +71,12 @@ int evl_get_cpustate(int cpu, int *state_r) return 0; } + +int evl_yield(void) +{ + if (evl_current == EVL_NO_HANDLE) + return -EPERM; + + /* This is our sched_yield(). */ + return oob_ioctl(evl_efd, EVL_THRIOC_YIELD) ? -errno : 0; +} diff --git a/tests/compile-tests/sched.cc b/tests/compile-tests/sched.cc index ffb59f7..abb2c89 100644 --- a/tests/compile-tests/sched.cc +++ b/tests/compile-tests/sched.cc @@ -22,6 +22,7 @@ int main(int argc, char *argv[]) param.quota.op = evl_quota_add; evl_control_sched(SCHED_QUOTA, ¶m, &info, 0); evl_get_cpustate(0, &cpu_state); + evl_yield(); return 0; }