linux cpu信息
/*
who参数
RUSAGE_SELF:只返回当前程序的CPU时间占用信息
RUSAGE_CHILDREN:还包括子进程的CPU时间占用信息
*/
int getrusage(int who, struct rusage *usage);
举例
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
int main()
{
struct rusage r_usage;
getrusage(RUSAGE_SELF, &r_usage);
printf("CPU usage: User = %ld.%06ld, System = %ld.%06ld\n",
r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec,
r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec);
return 0;
}
CPU usage: User = 0.000000, System = 0.000000
优先级
缺省优先级是0,合法优先级范围是-20到+20。数值越低代表有较高的优先次序,执行会较频繁
/*
who参数
PRIO_PROCESS 为进程识别码
PRIO_PGRP 为进程的组识别码
PRIO_USER 为用户识别码
*/
int getpriority(int which, int who);
int setpriority(int which, int who, int prio);
举例
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
int main()
{
int priority;
priority = getpriority(PRIO_PROCESS, getpid());
printf("Current priority = %d\n", priority);
return 0;
}
Current priority = 0
linux cpu信息的更多相关文章
- Linux CPU信息和使用情况查看(CentOS)
一.CPU信息查看 cat /proc/cpuinfo| grep "physical id"| sort -u | wc -l #查看是物理CPU个数,-u和uniq都是去重作用 ...
- linux cpu信息查看
转自:https://www.cnblogs.com/emanlee/p/3587571.html # 总核数 = 物理CPU个数 X 每颗物理CPU的核数 # 总逻辑CPU数 = 物理CPU个数 X ...
- Linux CPU信息说明
命令 [root@*** ~]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian ...
- Linux 查看CPU信息、机器型号等硬件信息
测试机器的硬件信息: 查看CPU信息(型号) # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 8 Intel(R) Xeo ...
- Linux查看CPU信息
1. 查看物理CPU的个数 #cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc –l 2. 查看逻辑CPU的个数 #ca ...
- Linux下查看CPU信息
在linux操作系统中,CPU的信息在启动的过程中被装载到虚拟目录/proc下的cpuinfo文件中,我们可以通过 cat /proc/cpuinfo 查看一下:
- Linux学习总结(十四)—— 查看CPU信息
文章首发于[博客园-陈树义],点击跳转到原文Linux学习总结(十四)-- 查看CPU信息. Linux学习总结(十四)-- 查看CPU信息 商用服务器CPU最常用的是 Intel Xeon 系列,该 ...
- Linux top命令中CPU信息的详解(转)
add by zhj: 下面的文章解释的很好了,这里再说明一下top命令中wa的含义,我们知道,当IO阻塞时,操作系统会把进程改为阻塞态,将CPU调度到运行其它进程. CPU在空闲状态下,会检查是否有 ...
- Linux下 查看CPU信息
参考: Linux和Windows下查看cpu和core个数 Linux下 查看CPU信息 1.查看完整CPU信息: $ cat /proc/cpuinfo 2.查看逻辑cpu个数: $ cat /p ...
随机推荐
- FCC---Use the CSS Transform scale Property to Change the Size of an Element
To change the scale of an element, CSS has the transform property, along with its scale() function. ...
- JS 逻辑
JS 逻辑 Boolean(逻辑)对象用于将非逻辑值转换为逻辑值(true 或者 false). Boolean 对象 您可以将 Boolean 对象理解为一个产生逻辑值的对象包装器. Boolean ...
- Flutter 基础控件
内容: Button Image.Icon Switch.Checkbox TextField Form 1.Button RaisedButton 漂浮按钮 FlatButton 扁平按钮 Outl ...
- 【Https异常】This request has been blocked; the content must be served over HTTPS
一.问题出现场景 项目从http升级到https后,jsp页面存在发送http请求的情况下就会出现该异常.因为HTTPS 是 HTTP over Secure Socket Layer,以安全为目标的 ...
- 201871010106-丁宣元 《面向对象程序设计(java)》第十二周学习总结
201871010106-丁宣元 <面向对象程序设计(java)>第十二周学习总结 正文开头: 项目 内容 这个作业属于哪个课程 https://home.cnblogs.com/u/nw ...
- Django celery 使用
0.安装包 cachetools 3.1.1 celery 3.1.26.post2 celery-with-redis 3.0 certifi 2019.9.11 Django 2.2.6 djan ...
- BZOJ2007/LG2046 「NOI2010」海拔 平面图最小割转对偶图最短路
问题描述 BZOJ2007 LG2046 题解 发现左上角海拔为 \(0\) ,右上角海拔为 \(1\) . 上坡要付出代价,下坡没有收益,所以有坡度的路越少越好. 所以海拔为 \(1\) 的点,和海 ...
- P3525 INS-Inspection
这道题的题面有点问题,如果按照题面做,应该是A不了的,下面引用一下评论里@REM_001的翻译 一棵n个节点的树,行动中心S从1->N.从S出发前往任意一个未标记到的点(沿树上两点的唯一路径走) ...
- Codeforces Round #594 (Div. 1) D. Catowice City 图论
D. Catowice City In the Catowice city next weekend the cat contest will be held. However, the jury m ...
- Codeforces Round #598 (Div. 3) D. Binary String Minimizing 贪心
D. Binary String Minimizing You are given a binary string of length n (i. e. a string consisting of ...