thread_arch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Koen Zandberg <koen@bergzand.net>
3  * 2021 Inria
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
20 #ifndef THREAD_ARCH_H
21 #define THREAD_ARCH_H
22 
23 #include "cpu_conf.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define THREAD_API_INLINED
30 
31 #ifndef DOXYGEN /* Doxygen is in core/include/thread.h */
32 
33 static inline __attribute__((always_inline)) void thread_yield_higher(void)
34 {
35  /* trigger the PENDSV interrupt to run scheduler and schedule new thread if
36  * applicable */
37  SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
38  /* flush the pipeline. Otherwise we risk that subsequent instructions are
39  * executed before the IRQ has actually triggered */
40  __ISB();
41 }
42 
43 #endif /* DOXYGEN */
44 
45 #ifdef __cplusplus
46 }
47 #endif
48 
49 #endif /* THREAD_ARCH_H */
THREAD_MAYBE_INLINE void thread_yield_higher(void)
Lets current thread yield in favor of a higher prioritized thread.