Chinaunix首页 | 论坛 | 博客
  • 博客访问: 732717
  • 博文数量: 79
  • 博客积分: 2671
  • 博客等级: 少校
  • 技术积分: 1247
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-02 15:26
个人简介

宅男

文章分类

全部博文(79)

文章存档

2017年(11)

2016年(12)

2015年(6)

2012年(10)

2011年(33)

2010年(7)

分类: LINUX

2011-04-25 20:04:10

1.今天再次读到了《情景分析》中的do_page_fault函数。对其中的一些代码感到比较疑惑。
  1. struct task_struct *tsk;
  2. tsk = current;
对于上面的这句代码感到不解。do_page_fault是由系统产生一个异常的时候调用的一个服务程序,显然操作系统处于内核态。
current最终会调用到下面的current_thread_info函数
  1. static inline struct thread_info *current_thread_info(void)
  2. {
  3.     register unsigned long sp asm ("sp");
  4.     return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
  5. }
具体是根据当前的栈针来获得task_struct结构体的。
但是当处理异常服务程序的时候,内核在内核态,获得不应该是造成异常的用户程序的task_struct呀,我到底是哪儿理解错了。。。。
Q:

阅读(1566) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~