2019独角兽企业重金招聘Python工程师标准>>>

\linux\include\linux\sched.h中定义的有关频率,load average的相关常数与变量
#define HZ 100  //定义时钟频率,两个时钟间隔时间为10ms
/** These are the constant used to fake the fixed-point load-average* counting. Some notes:                                                                       *  - 11 bit fractions expand to 22 bits by the multiplies: this gives 11bit*    a load-average precision of 10 bits integer + 11 bits fractional*  - if you want to count load-averages more often, you need more*    precision, or rounding will get you. With 2-second counting freq,*    the EXP_n values would be 1981, 2034 and 2043 if still using only*    11 bit fractions.*/
extern unsigned long avenrun[];     /* Load averages */#define FSHIFT       11      /* nr of bits of precision */
#define FIXED_1     (1<<FSHIFT)   /* 1.0 as fixed-point */
#define LOAD_FREQ   (5*HZ)      /* 5 sec intervals */
#define EXP_1       1884        /* 1/exp(5sec/1min) as fixed-point */
#define EXP_5       2014        /* 1/exp(5sec/5min) */
#define EXP_15      2037        /* 1/exp(5sec/15min) */
#define CALC_LOAD(load,exp,n) \    //n=active_tasks活动进程数 ,load各个exp计算得到的average loadload *= exp; \load += n*(FIXED_1-exp); \load >>= FSHIFT;
load=(exp*load+n*(2048-exp))>>11。由这个式子来看,所谓的load只与当前活跃进程数有关。
\linux-2.4.x\kernel\timer.c中定义load average的计算函数。
unsigned long avenrun[3];static inline void calc_load(unsigned long ticks)
{unsigned long active_tasks; /* fixed-point */static int count = LOAD_FREQ;count -= ticks;if (count < 0) {count += LOAD_FREQ;active_tasks = count_active_tasks();CALC_LOAD(avenrun[0], EXP_1, active_tasks);CALC_LOAD(avenrun[1], EXP_5, active_tasks);CALC_LOAD(avenrun[2], EXP_15, active_tasks);}
}
\linux-2.4.x\fs\proc\proc_misc.c中定义使用uptime命令时调用load average显示函数的实现方式
static int loadavg_read_proc(char *page, char **start, off_t off,int count, int *eof, void *data)
{int a, b, c;int len;a = avenrun[0] + (FIXED_1/200);b = avenrun[1] + (FIXED_1/200);c = avenrun[2] + (FIXED_1/200);len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",LOAD_INT(a), LOAD_FRAC(a),LOAD_INT(b), LOAD_FRAC(b),LOAD_INT(c), LOAD_FRAC(c),nr_running, nr_threads, last_pid);return proc_calc_metrics(page, start, off, count, eof, len);
}

http://www.yeeyan.org/articles/view/79184/37314

转载于:https://my.oschina.net/u/138195/blog/91490

load average相关推荐

  1. Load average in Linux的精确含义

    Man 上的解释: load average System load averages is the average number of processes that are either in a ...

  2. 老李分享:shell 监控cpu,memory,load average 1

    老李分享:shell 监控cpu,memory,load average poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课 ...

  3. LINUX下CPU Load Average的一点研究

    背景: 公司的某个系统工作在基于Linux的Cent OS下,一个host下同时连接了许多client, 最近某台Host总是显示CPU Load Average过高,我们单纯的以为是CPU的占用过高 ...

  4. 理解Linux系统中的load average(图文版)转载

    理解Linux系统中的load average(图文版) 博客分类: Linux linux load nagios  一.什么是load average? linux系统中的Load对当前CPU工作 ...

  5. linux中负载值为多少正常_Linux load average负载量分析与解决思路

    一.load average top命令中load average显示的是最近1分钟.5分钟和15分钟的系统平均负载.系统平均负载表示 系统平均负载被定义为在特定时间间隔内运行队列中(在CPU上运行或 ...

  6. linux主机load average的概念计算过程注意事项

    最近开发的一个模块需要根据机房各节点的负载情况(如网卡IO.load average等指标)做任务调度,刚开始对Linux机器load average这项指标不是很清楚,经过调研,终于搞清楚了其计算方 ...

  7. 如何理解和分析linux系统的CPU平均负载情况(load average)

    最近研究linux时接触到了一个新的概念,叫做CPU的平均负载(load average).之前都只听说过CPU的使用情况,很少听说过负载情况.于是对这个概念进行了一下研究学习,总结如下,以便日后查阅 ...

  8. 理解Linux系统中的load average

    一.什么是load average? linux系统中的Load对当前CPU工作量的度量 (WikiPedia: the system load is a measure of the amount ...

  9. 聊一聊Load Average

    背景 前段时间,由于有几个应用引入了 prometheus-net.DotNetRuntime 这个组件,导致系统 CPU 间歇性飙升.这是这个组件一个已知的雷.. 同样也引发了系统的 Load Av ...

最新文章

  1. 包含锚点平滑滚动效果/解决锚点链接碰到固定定位问题/导航选中背景变色/固顶/返回顶部效果全...
  2. 2017前端开发者必学清单
  3. gedit emacs
  4. Google Map App 问题集锦
  5. ORM框架之------Dapper,Net下无敌的ORM
  6. 牛客网暑期ACM多校训练营(第三场)H - Diff-prime Pairs
  7. c++ 等待子线程结束_?进程、线程、以及它们之间的区别与联系
  8. SQL:ISNULL
  9. 利用梯度下降法求解一元线性回归和多元线性回归
  10. mysql批量写入100万数据_Mysql数据库实践操作之————批量插入数据(100万级别的数据)-阿里云开发者社区...
  11. oracle重建orainventory,数据库重建oraInventory
  12. 系统权限安全责任书_权限越大,责任越大
  13. BP神经网络(手写数字识别)
  14. python中实现多路分支的最佳控制结构是_哪个选项是实现多路分支的最佳控制结构? (1.3分)_学小易找答案...
  15. java 跨平台的等宽字体_值得推荐的优秀编程字体/代码等宽字体收集(转)
  16. 浅谈MyBatis持久层框架
  17. 基于docker快速搭建自己的域名邮箱,mailu邮件服务器
  18. spring集成shiro原理
  19. 某网店营销策划方案(SWOT部分)
  20. 硬盘和硬盘驱动器的区别

热门文章

  1. Kubernetes的yaml文件中command的使用
  2. 比赛:小奔与不等四边形solution
  3. 使用Windows的分析等待链(analyze wait chain)来诊断没用响应的应用
  4. 关于谷歌浏览器 点击元素便签出现外边框的情况解决办法
  5. java--uploadify3.1多文件上传
  6. ASP.NET页面的CheckBoxList组件
  7. 为了缅怀Borland Delphi!!!
  8. 异常“只能在执行Render()的过程中调用RegisterForEventValidation”的解决办法(转)...
  9. linux 软链接_面试 | Linux 下软链接和硬链接的区别
  10. 不得自行对涉密计算机进行格式化,保密资格认证-涉密人员考试试题