1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

thread_yield_higher(): assert interrupts enabled

This commit is contained in:
Mihai Renea 2024-10-25 13:21:04 +02:00
parent ec4af87b99
commit fc76726519
8 changed files with 28 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include "list.h"
#include "cib.h"
#include "irq.h"
#include "msg.h"
#ifdef __cplusplus

View File

@ -121,6 +121,7 @@
#include "clist.h"
#include "cib.h"
#include "irq.h"
#include "msg.h"
#include "sched.h"
#include "thread_config.h"
@ -340,6 +341,11 @@ static inline void thread_yield(void)
}
#endif
/**
* @brief Arch-specific implementation of @ref thread_yield_higher()
*/
THREAD_MAYBE_INLINE void thread_yield_higher_arch(void);
/**
* @brief Lets current thread yield in favor of a higher prioritized thread.
*
@ -352,7 +358,21 @@ static inline void thread_yield(void)
*
* @see thread_yield()
*/
THREAD_MAYBE_INLINE void thread_yield_higher(void);
#ifdef DEBUG_THREAD_YIELD_HIGHER
/* A failed assertion will reveal where this was called at the expense of
* increased binary size. */
#define thread_yield_higher() do { \
assume(irq_is_in() || irq_is_enabled()); \
thread_yield_higher_arch(); \
} while (0)
#else
static inline void thread_yield_higher(void)
{
assume(irq_is_in() || irq_is_enabled());
thread_yield_higher_arch();
}
#endif
/**
* @brief Puts the current thread into zombie state.

View File

@ -30,7 +30,7 @@ extern "C" {
#ifndef DOXYGEN /* Doxygen is in core/include/thread.h */
static inline __attribute__((always_inline)) void thread_yield_higher(void)
static inline __attribute__((always_inline)) void thread_yield_higher_arch(void)
{
if (irq_is_in()) {
sched_context_switch_request = 1;

View File

@ -258,7 +258,7 @@ void NORETURN avr8_enter_thread_mode(void)
UNREACHABLE();
}
void thread_yield_higher(void)
void thread_yield_higher_arch(void)
{
if (!IS_USED(MODULE_CORE_THREAD)) {
return;

View File

@ -30,7 +30,7 @@ extern "C" {
#ifndef DOXYGEN /* Doxygen is in core/include/thread.h */
static inline __attribute__((always_inline)) void thread_yield_higher(void)
static inline __attribute__((always_inline)) void thread_yield_higher_arch(void)
{
/* trigger the PENDSV interrupt to run scheduler and schedule new thread if
* applicable */

View File

@ -33,7 +33,7 @@
* execution at the call site using reti.
*
*/
void thread_yield_higher(void)
void thread_yield_higher_arch(void)
{
if (irq_is_in()) {
sched_context_switch_request = 1;

View File

@ -241,7 +241,7 @@ void isr_thread_yield(void)
}
}
void thread_yield_higher(void)
void thread_yield_higher_arch(void)
{
sched_context_switch_request = 1;

View File

@ -43,7 +43,7 @@ static inline void _ecall_dispatch(uint32_t num, void *ctx)
);
}
static inline __attribute__((always_inline)) void thread_yield_higher(void)
static inline __attribute__((always_inline)) void thread_yield_higher_arch(void)
{
if (irq_is_in()) {
sched_context_switch_request = 1;