Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56349 )
Change subject: lib/thread: Add thread_yield helper method ......................................................................
lib/thread: Add thread_yield helper method
This helper method is just a shorthand for `thread_yield_microseconds(0)`. I think it makes it clear that we want to yield a thread without delaying.
BUG=b:179699789 TEST=build test
Suggested-by: Julius Werner jwerner@chromium.org Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Id8b60c35b183cff6871d7ba70b36eb33b136c735 --- M src/include/thread.h M src/lib/thread.c 2 files changed, 13 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/56349/1
diff --git a/src/include/thread.h b/src/include/thread.h index da8ed72..6df9d7e 100644 --- a/src/include/thread.h +++ b/src/include/thread.h @@ -33,6 +33,10 @@ * machine. */ int thread_run_until(void (*func)(void *), void *arg, boot_state_t state, boot_state_sequence_t seq); + +/* Return 0 on successful yield, < 0 when thread did not yield. */ +int thread_yield(void); + /* Return 0 on successful yield for the given amount of time, < 0 when thread * did not yield. */ int thread_yield_microseconds(unsigned int microsecs); @@ -64,6 +68,10 @@ { return -1; } +static inline int thread_yield(void) +{ + return -1; +} static inline int thread_yield_microseconds(unsigned int microsecs) { return -1; diff --git a/src/lib/thread.c b/src/lib/thread.c index 782a63e..a8c0772c 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -332,6 +332,11 @@ return 0; }
+int thread_yield(void) +{ + return thread_yield_microseconds(0); +} + int thread_yield_microseconds(unsigned int microsecs) { struct thread *current;