启动调度器 调度器的启动由函数rt_system_scheduler_start()来实现,具体代码如下: - /* 启动系统调度器 */
- void rt_system_scheduler_start(void)
- {
- register struct rt_thread *to_thread;
-
- /* 手动指定第一个运行的线程 */
- to_thread = rt_list_entry(rt_thread_priority_table[0].next,
- struct rt_thread,
- tlist);
- rt_current_thread = to_thread;
-
- /*
- 切换到第一个线程,改函数在context_rvds.S中实现,
- 在rthw.h声明,用于实现第一次线程切换。
- 当一个汇编函数在C文件中调用的时候,如果有形参,
- 则执行的时候会将形参传入CPU寄存器r0
- */
- rt_hw_context_switch_to((rt_uint32_t)&to_thread->sp);
- }
|