免费注册 查看新帖 |

Chinaunix

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

进程时间片 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-10-21 19:50 |只看该作者 |倒序浏览
1. 进程在调用内核函数运行时,这时运行的内核函数有没有优先级这个概念的?如果有的话是不是代表了该进程的优先级?
   2.当进程调用内核函数时,这时进程的时间片有没有消耗,还是说运行在用户态才会消耗时间片?

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
2 [报告]
发表于 2010-10-21 19:52 |只看该作者
1. 进程在调用内核函数运行时,这时运行的内核函数有没有优先级这个概念的?如果有的话是不是代表了该进程的 ...
colinchhe 发表于 2010-10-21 19:50



  2. 昨天和朋友讨论过了,有,有个patch,可以让他没有,细节http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-tip.git;a=commitdiff;h=b52bfee445d315549d41eacf2fa7c156e7d153d5

论坛徽章:
0
3 [报告]
发表于 2010-10-22 10:52 |只看该作者
我看书上说,现在的调度器不用时间片了

论坛徽章:
0
4 [报告]
发表于 2010-10-22 14:16 |只看该作者
我用的是2.6.31版本,不用时间片,那么用什么了?

论坛徽章:
0
5 [报告]
发表于 2010-10-22 14:19 |只看该作者
2. 昨天和朋友讨论过了,有,有个patch,可以让他没有,细节;a=commitdiff;h=b52bfee445d315549d41 ...
T-Bagwell 发表于 2010-10-21 19:52



   
  问题1,是不是代表当前的调用这个内核函数的进程优先级?

问题2,可以通过补丁形式让进程在调用内核函数时不消耗时间片?

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
6 [报告]
发表于 2010-10-22 14:42 |只看该作者
问题1,是不是代表当前的调用这个内核函数的进程优先级?

问题2,可以通过补丁形式让进 ...
colinchhe 发表于 2010-10-22 14:19

  1. does
  2. the fine granularity accounting of user, system, hardirq, softirq times.
  3. Adding that option on archs like x86 will be challenging however, given the
  4. state of TSC reliability on various platforms and also the overhead it will
  5. add in syscall entry exit.

  6. Instead, add a lighter variant that only does finer accounting of
  7. hardirq and softirq times, providing precise irq times (instead of timer tick
  8. based samples). This accounting is added with a new config option
  9. CONFIG_IRQ_TIME_ACCOUNTING so that there won't be any overhead for users not
  10. interested in paying the perf penalty.

  11. This accounting is based on sched_clock, with the code being generic.
  12. So, other archs may find it useful as well.

  13. This patch just adds the core logic and does not enable this logic yet







  14. +static DEFINE_PER_CPU(u64, cpu_hardirq_time);
  15. +static DEFINE_PER_CPU(u64, cpu_softirq_time);
  16. +
  17. +static DEFINE_PER_CPU(u64, irq_start_time);
  18. +static int sched_clock_irqtime;
  19. +
  20. +void enable_sched_clock_irqtime(void)
  21. +{
  22. +       sched_clock_irqtime = 1;
  23. +}
  24. +
  25. +void disable_sched_clock_irqtime(void)
  26. +{
  27. +       sched_clock_irqtime = 0;
  28. +}
  29. +
  30. +void account_system_vtime(struct task_struct *curr)
  31. +{
  32. +       unsigned long flags;
  33. +       int cpu;
  34. +       u64 now, delta;
  35. +
  36. +       if (!sched_clock_irqtime)
  37. +               return;
  38. +
  39. +       local_irq_save(flags);
  40. +
  41. +       now = sched_clock();
  42. +       cpu = smp_processor_id();
  43. +       delta = now - per_cpu(irq_start_time, cpu);
  44. +       per_cpu(irq_start_time, cpu) = now;
  45. +       /*
  46. +        * We do not account for softirq time from ksoftirqd here.
  47. +        * We want to continue accounting softirq time to ksoftirqd thread
  48. +        * in that case, so as not to confuse scheduler with a special task
  49. +        * that do not consume any time, but still wants to run.
  50. +        */
  51. +       if (hardirq_count())
  52. +               per_cpu(cpu_hardirq_time, cpu) += delta;
  53. +       else if (in_serving_softirq() && !(curr->flags & PF_KSOFTIRQD))
  54. +               per_cpu(cpu_softirq_time, cpu) += delta;
  55. +
  56. +       local_irq_restore(flags);
  57. +}
  58. +
  59. +#endif
  60. +
复制代码
就是说,如果sched_clock_irqtime=0,就return了,就不now = sched_clock();了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP