local_irq_save(flags) 是如何将中断系统的状态保存到flags中的
看local_irq_save(flags) 函数,参数flags是以值传递的方式传递的,不知道这样怎么会把系统中的中断状态保存到参数flags中。看《linux 内核设计与实现中》说的,因为local_irq_save至少部分是以宏形式定义的,所以参数flags是以值传递的方式传递的。
LDD 内容:
Note that these methods are implemented at least in part as macros, so the flags parameter (which must be defined as an unsigned long ) is seemingly passed by value.
This parameter contains architecture-specific data containing the state of the interrupt systems. Because at least one supported architecture incorporates stack information into the value (ahem, SPARC), flags cannotbe passed to another function (specifically, it must remain on the same stack frame).
For this reason, the call to save and the call to restore interrupts must occur in the same function.
红色部分我没看明白,因为从宏定义中看,flags作为输出参数,函数是将中断信息保存到此参数中。而红色部分说flags中保存中断系统的状态的具体体系结构的数据,搞不懂这些数据如何保存的。
2.6.32的内核local_irq_save(flags)代码:static int signals_enabled
.......
int get_signals(void)
{
return signals_enabled;
}
#define local_save_flags(flags) do { typecheck(unsigned long, flags); \
(flags) = get_signals(); } while(0) 我自己搞错了,因为local_irq_save(flags)是宏定义。
页:
[1]