Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
arch_inlines.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Meta Platforms.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_ZEPHYR_ARCH_COMMON_ARCH_INLINES_H_
8#define ZEPHYR_INCLUDE_ZEPHYR_ARCH_COMMON_ARCH_INLINES_H_
9
10#ifndef ZEPHYR_INCLUDE_ARCH_INLINES_H_
11#error "This header shouldn't be included directly"
12#endif /* ZEPHYR_INCLUDE_ARCH_INLINES_H_ */
13
14#ifndef _ASMLANGUAGE
15
17
18#ifndef CONFIG_ARCH_HAS_CUSTOM_CURRENT_IMPL
20{
21#ifdef CONFIG_SMP
22 /* In SMP, arch_current_thread() is a field read from _current_cpu, which
23 * can race with preemption before it is read. We must lock
24 * local interrupts when reading it.
25 */
26 unsigned int k = arch_irq_lock();
27
28 struct k_thread *ret = _current_cpu->current;
29
31#else
32 struct k_thread *ret = _kernel.cpus[0].current;
33#endif /* CONFIG_SMP */
34 return ret;
35}
36
38{
39 _current_cpu->current = thread;
40}
41#endif /* CONFIG_ARCH_HAS_CUSTOM_CURRENT_IMPL */
42
43#endif /* _ASMLANGUAGE */
44
45#endif /* ZEPHYR_INCLUDE_ZEPHYR_ARCH_COMMON_ARCH_INLINES_H_ */
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Disable all interrupts on the local CPU.
Definition irq.h:168
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition irq.h:176
static ALWAYS_INLINE struct k_thread * arch_current_thread(void)
Definition arch_inlines.h:19
static ALWAYS_INLINE void arch_current_thread_set(struct k_thread *thread)
Definition arch_inlines.h:37
#define ALWAYS_INLINE
Definition common.h:129
Thread Structure.
Definition thread.h:259