[v1.2.0 beta] ISR中调用rt_schedule()
打算用mailbox实现ISR跟普通线程的通信,ISR中调用rt_mb_send()发送邮件。但是,看了一下rt_mb_send()的代码,它在发送邮件后,会调用rt_schedule(),唤醒被阻塞的线程。
问题是,调用rt_schedule()时,尚处于中断上下文中,处理器还没脱离异常模式,此时为什么能唤醒普通线程? 在rt_schedule()中:if (rt_interrupt_nest == 0)
{
rt_hw_context_switch((rt_uint32_t)&from_thread->sp,
(rt_uint32_t)&to_thread->sp);
}
else
{
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n"));
rt_hw_context_switch_interrupt((rt_uint32_t)&from_thread->sp,
(rt_uint32_t)&to_thread->sp);
}
这个是RTT的说明文档,上面推荐用mailbox实现ISR-线程通信 。。。睁着大眼没看见,只看见对rt_scheduler_lock_nest的判断了
多谢,我再看看。
页:
[1]