阅 读 文 章

linux内核原代码sched.c的注释

[来源:网上转载 (http://www.chinaunix.net) | 作者:网友(不详) | 时间:2007-07-07 | 浏览:人次 ]

  /*
  * 'sched.c' is the main kernel file. It contains scheduling primitives
  * (sleep_on, wakeup, schedule etc) as well as a number of simple system
  * call functions (type getpid(), which just extracts a field from
  * current-task
  */
  #include
  #include
  #include
  #include
  #include
  #include
  #include

#define LATCH (1193180/HZ)

extern void mem_use(void);

extern int timer_interrupt(void);
  extern int system_call(void);

union task_union {
  struct task_struct task;
  char stack[PAGE_SIZE];
  };

static union task_union init_task = {INIT_TASK,};

long volatile jiffies=0;
  long startup_time=0;
  struct task_struct *current = &(init_task.task), *last_task_used_math =
  NULL;

struct task_struct * task[NR_TASKS] = {&(init_task.task), };

long user_stack [ PAGE_SIZE>>2 ] ;

struct {
  long * a;
  short b;
  } stack_start = { & user_stack [PAGE_SIZE>>2] , 0x10 };
  /*
  * 'math_state_restore()' saves the current math information in the
  * old math state array, and gets the new ones from the current task
  */
  void math_state_restore() @@协处理器状态保存
  {
  if (last_task_used_math)
   __asm__("fnsave %0"::"m" (last_task_used_math->tss.i387));
  if (current->used_math)
   __asm__("frstor %0"::"m" (current->tss.i387));
  else {
   __asm__("fninit"::);
   current->used_math=1;
  }
  last_task_used_math=current;
  }

/*
  * 'schedule()' is the scheduler function. This is GOOD CODE! There
  * probably won't be any reason to change this, as it should work well
  * in all circumstances (ie gives IO-bound processes good response etc).

* The one thing you might take a look at is the signal-handler code
  here.
  *
  * NOTE!! Task 0 is the 'idle' task, which gets called when no other
  * tasks can run. It can not be killed, and it cannot sleep. The 'state'

* information in task[0] is never used.
  */
  void schedule(void)
  {
  int i,next,c;
  struct task_struct ** p;

/* check alarm, wake up any interruptible tasks that have got a signal
  */

for(p = &LAST_TASK ; p >&FIRST_TASK ; --p)
   if (*p) {
   if ((*p)->alarm && (*p)->alarm signal |= (1alarm = 0;
   }
   if ((*p)->signal && (*p)->state==TASK_INTERRUPTIBLE)

论坛热门帖子: [lch203] 写得蛮好的linux学习笔记(10-21)
[黑马制造] 学习java的30个目标(10-19)
[笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19)
[udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18)
[沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18)
TAG标签: 注释 代码 void if return int @@ case long struct task

最新评论 共有0位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表

网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.chmhome.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.