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 
10 #pragma once
11 
22 #include "cpu_conf.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define THREAD_API_INLINED
29 
30 #ifndef DOXYGEN /* Doxygen is in core/include/thread.h */
31 
32 static inline __attribute__((always_inline)) void thread_yield_higher(void)
33 {
34  /* trigger the PENDSV interrupt to run scheduler and schedule new thread if
35  * applicable */
36  SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
37  /* flush the pipeline. Otherwise we risk that subsequent instructions are
38  * executed before the IRQ has actually triggered */
39  __ISB();
40 }
41 
42 #endif /* DOXYGEN */
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
THREAD_MAYBE_INLINE void thread_yield_higher(void)
Lets current thread yield in favor of a higher prioritized thread.