Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56319 )
Change subject: lib/thread: Add thread_coop_enabled ......................................................................
lib/thread: Add thread_coop_enabled
This method exposes if the current thread can coop. It will be used in the following patch.
BUG=b:179699789 TEST=none
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: I90060e21f127fb725f126163aa5b2be6b9d1d117 --- M src/include/thread.h M src/lib/thread.c 2 files changed, 17 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/19/56319/1
diff --git a/src/include/thread.h b/src/include/thread.h index da8ed72..1da9c01 100644 --- a/src/include/thread.h +++ b/src/include/thread.h @@ -43,6 +43,7 @@ * only a single place where switching may occur: a call to udelay(). */ void thread_cooperate(void); void thread_prevent_coop(void); +bool thread_coop_enabled(void);
static inline void thread_init_cpu_info_non_bsp(struct cpu_info *ci) { @@ -70,6 +71,10 @@ } static inline void thread_cooperate(void) {} static inline void thread_prevent_coop(void) {} +static inline bool thread_coop_enabled(void) +{ + return false; +} struct cpu_info; static inline void thread_init_cpu_info_non_bsp(struct cpu_info *ci) { } #endif diff --git a/src/lib/thread.c b/src/lib/thread.c index 782a63e..9eed5e1 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -367,3 +367,15 @@ if (current != NULL) current->can_yield = 0; } + +bool thread_coop_enabled(void) +{ + struct thread *current; + + current = current_thread(); + + if (current != NULL) + return current->can_yield; + + return false; +}