From 2c497f70c27fdb6ce48aa46891f788ffde9ed5b9 Mon Sep 17 00:00:00 2001 From: VAN BOSSUYT Nicolas Date: Thu, 2 Jan 2025 16:24:32 +0100 Subject: [PATCH] hjert-core: Added a small fast path in Task::block(). --- src/kernel/hjert-core/task.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/kernel/hjert-core/task.cpp b/src/kernel/hjert-core/task.cpp index 2dad8a7ef6c..757b364899a 100644 --- a/src/kernel/hjert-core/task.cpp +++ b/src/kernel/hjert-core/task.cpp @@ -57,6 +57,10 @@ Res<> Task::ready(usize ip, usize sp, Hj::Args args) { } Res<> Task::block(Blocker blocker) { + // NOTE: If the blocker is already expired, don't block. + if (blocker() <= globalSched()._stamp) + return Ok(); + // NOTE: Can't use ObjectLockScope here because // we need to yield outside of the lock. _lock.acquire();