1 #ifndef __LUNAIX_KPREEMPT_H
2 #define __LUNAIX_KPREEMPT_H
6 #include <lunaix/process.h>
9 __attribute__((section(".kf.preempt"))) no_inline
11 #define ensure_preempt_caller() \
13 extern int __kf_preempt_start[]; \
14 extern int __kf_preempt_end[]; \
15 ptr_t _retaddr = abi_get_retaddr(); \
16 assert_msg((ptr_t)__kf_preempt_start <= _retaddr \
17 && _retaddr < (ptr_t)__kf_preempt_end, \
18 "caller must be kernel preemptible"); \
24 cpu_enable_interrupt();
30 cpu_disable_interrupt();
36 current_thread->stats.last_reentry = clock_systime();
43 * @brief preempt the current thread, and yield the remaining
44 * time slice to other threads.
46 * The current thread is marked as if it is being
47 * preempted involuntarily by kernel.
54 thread_stats_update_kpreempt();
59 * @brief yield the remaining time slice to other threads.
61 * The current thread is marked as if it is being
62 * preempted voluntarily by itself.
73 preempt_check_stalled(struct thread* th);
75 #endif /* __LUNAIX_KPREEMPT_H */