From e90c74304bde38211b74624a559fcfd51f581431 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sat, 16 May 2020 02:23:50 +0530 Subject: [PATCH] solo5: do not yield for expired deadlines --- packages/solo5/default.nix | 2 +- packages/solo5/time.patch | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 packages/solo5/time.patch diff --git a/packages/solo5/default.nix b/packages/solo5/default.nix index 39b780d..2d8c681 100644 --- a/packages/solo5/default.nix +++ b/packages/solo5/default.nix @@ -20,7 +20,7 @@ in stdenv.mkDerivation { enableParallelBuilding = true; - patches = [ ./genode.patch ./elftool.patch ]; + patches = [ ./genode.patch ./elftool.patch ./time.patch ]; configurePhase = '' runHook preConfigure diff --git a/packages/solo5/time.patch b/packages/solo5/time.patch new file mode 100644 index 0000000..ab0da2e --- /dev/null +++ b/packages/solo5/time.patch @@ -0,0 +1,60 @@ +commit a7902e24ba8fd2c6cfd56f68952f8d5417b9a303 +Author: Emery Hemingway +Date: Sat May 16 02:07:54 2020 +0530 + + Genode: do not yield for expired deadlines + +diff --git a/bindings/genode/bindings.cc b/bindings/genode/bindings.cc +index 5785ae5..a4a4a34 100644 +--- a/bindings/genode/bindings.cc ++++ b/bindings/genode/bindings.cc +@@ -104,6 +104,12 @@ namespace Solo5 + + return epoch; + } ++ ++ static Microseconds from_ns(solo5_time_t ns) { ++ return Microseconds { ns / 1000ULL }; } ++ ++ static solo5_time_t to_ns(Microseconds us) { ++ return us.value * 1000ULL; } + } + + +@@ -431,20 +437,19 @@ struct Solo5::Platform + _initial_epoch = rtc_epoch(env); + + return _initial_epoch * 1000000000ULL +- + timer.curr_time().trunc_to_plain_us().value * 1000ULL; ++ + to_ns(timer.curr_time().trunc_to_plain_us()); + } + + void + yield(solo5_time_t deadline_ns, solo5_handle_set_t *ready_set) + { + if (!nic_ready) { +- solo5_time_t deadline_us = deadline_ns / 1000; +- solo5_time_t now_us = timer.curr_time() +- .trunc_to_plain_us().value; ++ Microseconds deadline = from_ns(deadline_ns); ++ Microseconds now = timer.curr_time().trunc_to_plain_us(); ++ if (deadline.value <= now.value) return; + + // schedule a timeout signal +- yield_timeout.schedule( +- Genode::Microseconds{deadline_us - now_us}); ++ yield_timeout.schedule(Microseconds {deadline.value - now.value}); + + /* + * Block for Nic and Timer signals until a packet is +@@ -531,8 +536,8 @@ void solo5_abort(void) + + solo5_time_t solo5_clock_monotonic(void) + { +- return Platform::instance->timer.curr_time() +- .trunc_to_plain_us().value*1000; ++ return Solo5::to_ns(Platform::instance-> ++ timer.curr_time().trunc_to_plain_us()); + } + +