免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4441 | 回复: 1
打印 上一主题 下一主题

local_irq_save(flags) 是如何将中断系统的状态保存到flags中的 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-09 11:15 |只看该作者 |倒序浏览
看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 cannot  be 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)代码:
  1. static int signals_enabled
  2. .......

  3. int get_signals(void)
  4. {
  5.         return signals_enabled;
  6. }

  7. #define local_save_flags(flags) do { typecheck(unsigned long, flags); \
  8.                                      (flags) = get_signals(); } while(0)
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-04-09 15:50 |只看该作者
我自己搞错了,因为local_irq_save(flags)是宏定义。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP