博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux cpu占用率
阅读量:4193 次
发布时间:2019-05-26

本文共 1910 字,大约阅读时间需要 6 分钟。

cpu 占用率之 wa

wa 占用率为100%时,并不是 cpu 在忙转,此时cpu 一直执行idle 进程。 

void __sched io_schedule(void)

{
struct rq *rq = raw_rq();
delayacct_blkio_start();
atomic_inc(&rq->nr_iowait);
current->in_iowait = 1;
schedule();
current->in_iowait = 0;
atomic_dec(&rq->nr_iowait);
delayacct_blkio_end();
}

update_process_times->account_process_tick

void account_process_tick(struct task_struct *p, int user_tick)

{
cputime_t one_jiffy_scaled = cputime_to_scaled(cputime_one_jiffy);
struct rq *rq = this_rq();
if (user_tick)
account_user_time(p, cputime_one_jiffy, one_jiffy_scaled);
else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET))
account_system_time(p, HARDIRQ_OFFSET, cputime_one_jiffy,
   one_jiffy_scaled);
else
account_idle_time(cputime_one_jiffy);
}

void account_idle_time(cputime_t cputime)

{
struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
cputime64_t cputime64 = cputime_to_cputime64(cputime);
struct rq *rq = this_rq();
if (atomic_read(&rq->nr_iowait) > 0)
cpustat->iowait = cputime64_add(cpustat->iowait, cputime64);
else
cpustat->idle = cputime64_add(cpustat->idle, cputime64);
}

s3c2410_timer_interrupt ->timer_tick ->

void timer_tick(void)

{
profile_tick(CPU_PROFILING);
do_leds();
do_set_rtc();
write_seqlock(&xtime_lock);
do_timer(1);
write_sequnlock(&xtime_lock);
#ifndef CONFIG_SMP
update_process_times(user_mode(get_irq_regs()));
#endif
}

void do_timer(unsigned long ticks)

{
jiffies_64 += ticks;
update_wall_time();
calc_global_load();
}

cpu 占用率之 ni :

tmp = cputime_to_cputime64(cputime);

if (TASK_NICE(p) > 0)
cpustat->nice = cputime64_add(cpustat->nice, tmp);
else
cpustat->user = cputime64_add(cpustat->user, tmp);

/*

 * Convert user-nice values [ -20 ... 0 ... 19 ]
 * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
 * and back.
 */
#define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20)
#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
#define TASK_NICE(p) PRIO_TO_NICE((p)->static_prio)

转载地址:http://ptloi.baihongyu.com/

你可能感兴趣的文章
wpf image资源释放问题
查看>>
apache tomcat 安装配置
查看>>
eclipse maven创建一个普通java项目
查看>>
java 发送https post请求
查看>>
java 显示顶层提示窗口
查看>>
java PrintWriter输出中文乱码的解决
查看>>
eclipse maven项目生成war包
查看>>
XML Schema和DTD的区别
查看>>
java web 配置文件
查看>>
xml详解
查看>>
vue前端UI框架
查看>>
windows 使用bat增加环境变量
查看>>
idea 创建第一个web项目
查看>>
java中xml的解析
查看>>
http watch工具的使用
查看>>
验证码VerifyCode
查看>>
登录+验证码
查看>>
Eclipse中启动tomcat访问404解决及原因
查看>>
jsp详解
查看>>
jsp 导入自己写的类并使用输出
查看>>