RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
scheduler_mp.c 文件参考
#include <rtthread.h>
#include <rthw.h>
#include <rtdbg.h>
+ scheduler_mp.c 的引用(Include)关系图:

浏览该文件的源代码.

宏定义

#define DBG_TAG   "kernel.scheduler"
 
#define DBG_LVL   DBG_INFO
 
#define SCHEDULER_LOCK_FLAG(percpu)
 
#define SCHEDULER_ENTER_CRITICAL(curthr)
 
#define SCHEDULER_EXIT_CRITICAL(curthr)
 
#define SCHEDULER_CONTEXT_LOCK(percpu)
 
#define SCHEDULER_CONTEXT_UNLOCK(percpu)
 
#define SCHEDULER_LOCK(level)
 
#define SCHEDULER_UNLOCK(level)
 
#define IS_CRITICAL_SWITCH_PEND(pcpu, curthr)
 
#define SET_CRITICAL_SWITCH_FLAG(pcpu, curthr)
 
#define CLR_CRITICAL_SWITCH_FLAG(pcpu, curthr)
 

函数

rt_inline void _fast_spin_lock (struct rt_spinlock *lock)
 
rt_inline void _fast_spin_unlock (struct rt_spinlock *lock)
 
rt_inline rt_base_t _get_global_highest_ready_prio (void)
 
rt_inline rt_base_t _get_local_highest_ready_prio (struct rt_cpu *pcpu)
 
void rt_system_scheduler_init (void)
 
void rt_system_scheduler_start (void)
 

变量

rt_list_t rt_thread_priority_table [RT_THREAD_PRIORITY_MAX]
 

宏定义说明

◆ DBG_TAG

#define DBG_TAG   "kernel.scheduler"

在文件 scheduler_mp.c42 行定义.

◆ DBG_LVL

#define DBG_LVL   DBG_INFO

在文件 scheduler_mp.c43 行定义.

◆ SCHEDULER_LOCK_FLAG

#define SCHEDULER_LOCK_FLAG ( percpu)
值:
((percpu)->sched_lock_flag)

在文件 scheduler_mp.c49 行定义.

◆ SCHEDULER_ENTER_CRITICAL

#define SCHEDULER_ENTER_CRITICAL ( curthr)
值:
do \
{ \
if (curthr) RT_SCHED_CTX(curthr).critical_lock_nest++; \
} while (0)
#define RT_SCHED_CTX(thread)

在文件 scheduler_mp.c51 行定义.

51#define SCHEDULER_ENTER_CRITICAL(curthr) \
52 do \
53 { \
54 if (curthr) RT_SCHED_CTX(curthr).critical_lock_nest++; \
55 } while (0)

◆ SCHEDULER_EXIT_CRITICAL

#define SCHEDULER_EXIT_CRITICAL ( curthr)
值:
do \
{ \
if (curthr) RT_SCHED_CTX(curthr).critical_lock_nest--; \
} while (0)

在文件 scheduler_mp.c57 行定义.

57#define SCHEDULER_EXIT_CRITICAL(curthr) \
58 do \
59 { \
60 if (curthr) RT_SCHED_CTX(curthr).critical_lock_nest--; \
61 } while (0)

◆ SCHEDULER_CONTEXT_LOCK

#define SCHEDULER_CONTEXT_LOCK ( percpu)
值:
do \
{ \
RT_ASSERT(SCHEDULER_LOCK_FLAG(percpu) == 0); \
_fast_spin_lock(&_mp_scheduler_lock); \
SCHEDULER_LOCK_FLAG(percpu) = 1; \
} while (0)
#define SCHEDULER_LOCK_FLAG(percpu)

在文件 scheduler_mp.c63 行定义.

63#define SCHEDULER_CONTEXT_LOCK(percpu) \
64 do \
65 { \
66 RT_ASSERT(SCHEDULER_LOCK_FLAG(percpu) == 0); \
67 _fast_spin_lock(&_mp_scheduler_lock); \
68 SCHEDULER_LOCK_FLAG(percpu) = 1; \
69 } while (0)

◆ SCHEDULER_CONTEXT_UNLOCK

#define SCHEDULER_CONTEXT_UNLOCK ( percpu)
值:
do \
{ \
RT_ASSERT(SCHEDULER_LOCK_FLAG(percpu) == 1); \
SCHEDULER_LOCK_FLAG(percpu) = 0; \
_fast_spin_unlock(&_mp_scheduler_lock); \
} while (0)

在文件 scheduler_mp.c71 行定义.

71#define SCHEDULER_CONTEXT_UNLOCK(percpu) \
72 do \
73 { \
74 RT_ASSERT(SCHEDULER_LOCK_FLAG(percpu) == 1); \
75 SCHEDULER_LOCK_FLAG(percpu) = 0; \
76 _fast_spin_unlock(&_mp_scheduler_lock); \
77 } while (0)

◆ SCHEDULER_LOCK

#define SCHEDULER_LOCK ( level)
值:
do \
{ \
rt_thread_t _curthr; \
struct rt_cpu *_percpu; \
_percpu = rt_cpu_self(); \
_curthr = _percpu->current_thread; \
SCHEDULER_ENTER_CRITICAL(_curthr); \
SCHEDULER_CONTEXT_LOCK(_percpu); \
} while (0)
struct rt_cpu * rt_cpu_self(void)
This fucntion will return current cpu object.
struct rt_thread * rt_thread_t
#define rt_hw_local_irq_disable
定义 rthw.h:152
struct rt_thread * current_thread

在文件 scheduler_mp.c79 行定义.

79#define SCHEDULER_LOCK(level) \
80 do \
81 { \
82 rt_thread_t _curthr; \
83 struct rt_cpu *_percpu; \
84 level = rt_hw_local_irq_disable(); \
85 _percpu = rt_cpu_self(); \
86 _curthr = _percpu->current_thread; \
87 SCHEDULER_ENTER_CRITICAL(_curthr); \
88 SCHEDULER_CONTEXT_LOCK(_percpu); \
89 } while (0)

◆ SCHEDULER_UNLOCK

#define SCHEDULER_UNLOCK ( level)
值:
do \
{ \
rt_thread_t _curthr; \
struct rt_cpu *_percpu; \
_percpu = rt_cpu_self(); \
_curthr = _percpu->current_thread; \
SCHEDULER_CONTEXT_UNLOCK(_percpu); \
SCHEDULER_EXIT_CRITICAL(_curthr); \
rt_hw_local_irq_enable(level); \
} while (0)

在文件 scheduler_mp.c91 行定义.

91#define SCHEDULER_UNLOCK(level) \
92 do \
93 { \
94 rt_thread_t _curthr; \
95 struct rt_cpu *_percpu; \
96 _percpu = rt_cpu_self(); \
97 _curthr = _percpu->current_thread; \
98 SCHEDULER_CONTEXT_UNLOCK(_percpu); \
99 SCHEDULER_EXIT_CRITICAL(_curthr); \
100 rt_hw_local_irq_enable(level); \
101 } while (0)

◆ IS_CRITICAL_SWITCH_PEND

#define IS_CRITICAL_SWITCH_PEND ( pcpu,
curthr )
值:
((pcpu)->critical_switch_flag)

在文件 scheduler_mp.c109 行定义.

◆ SET_CRITICAL_SWITCH_FLAG

#define SET_CRITICAL_SWITCH_FLAG ( pcpu,
curthr )
值:
((pcpu)->critical_switch_flag = 1)

在文件 scheduler_mp.c110 行定义.

◆ CLR_CRITICAL_SWITCH_FLAG

#define CLR_CRITICAL_SWITCH_FLAG ( pcpu,
curthr )
值:
((pcpu)->critical_switch_flag = 0)

在文件 scheduler_mp.c111 行定义.

函数说明

◆ _fast_spin_lock()

rt_inline void _fast_spin_lock ( struct rt_spinlock * lock)

Used only on scheduler for optimization of control flows, where the critical region is already guaranteed.

在文件 scheduler_mp.c125 行定义.

126{
127 rt_hw_spin_lock(&lock->lock);
128
129 RT_SPIN_LOCK_DEBUG(lock);
130}
#define rt_hw_spin_lock(lock)
定义 rthw.h:235
#define RT_SPIN_LOCK_DEBUG(lock)
rt_ubase_t lock

引用了 rt_spinlock::lock, rt_hw_spin_lock , 以及 RT_SPIN_LOCK_DEBUG.

+ 这是这个函数的调用关系图:

◆ _fast_spin_unlock()

rt_inline void _fast_spin_unlock ( struct rt_spinlock * lock)

在文件 scheduler_mp.c132 行定义.

133{
134 rt_base_t critical_level;
135 RT_SPIN_UNLOCK_DEBUG(lock, critical_level);
136
137 /* for the scenario of sched, we don't check critical level */
138 RT_UNUSED(critical_level);
139
140 rt_hw_spin_unlock(&lock->lock);
141}
#define RT_UNUSED(x)
#define rt_hw_spin_unlock(lock)
定义 rthw.h:236
rt_int32_t rt_base_t
#define RT_SPIN_UNLOCK_DEBUG(lock, critical)

引用了 rt_spinlock::lock, rt_hw_spin_unlock, RT_SPIN_UNLOCK_DEBUG , 以及 RT_UNUSED.

+ 这是这个函数的调用关系图:

◆ _get_global_highest_ready_prio()

rt_inline rt_base_t _get_global_highest_ready_prio ( void )

在文件 scheduler_mp.c216 行定义.

217{
218 return __rt_ffs(rt_thread_ready_priority_group) - 1;
219}
int __rt_ffs(int value)
This function finds the first bit set (beginning with the least significant bit) in value and return ...

引用了 __rt_ffs().

+ 函数调用图:

◆ _get_local_highest_ready_prio()

rt_inline rt_base_t _get_local_highest_ready_prio ( struct rt_cpu * pcpu)

在文件 scheduler_mp.c221 行定义.

222{
223 return __rt_ffs(pcpu->priority_group) - 1;
224}

引用了 __rt_ffs().

+ 函数调用图:

变量说明

◆ rt_thread_priority_table

rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX]

在文件 scheduler_mp.c46 行定义.