让机器所有的cpu核打满
来源:互联网 发布:tp路由器mac地址修改器 编辑:程序博客网 时间:2024/06/05 20:31
让机器所有的cpu核打满
下面的程序可以将一个机器所有的cpu核打满:
#include <stdio.h>#include <stdlib.h>#include <errno.h>#define __USE_GNU#include <sched.h>#include <sys/time.h>#include <sys/resource.h>#include <pthread.h>void thread_func(int n){ cpu_set_t mask; CPU_ZERO(&mask); CPU_SET(n,&mask); if (sched_setaffinity(0, sizeof(mask), &mask) == -1) { printf("warning: could not set CPU affinity, continuing...\n"); } nice(-1); int pid[1]; struct sched_param p[1]; struct sched_param para; para.sched_priority = 23; sched_setscheduler(0, SCHED_FIFO, ¶); printf("Parent pid is %d policy is %d, prio:%d\n", getpid(), sched_getscheduler(0), para.sched_priority); while(1) { }}int main(int argc, char *argv[]){ int i = 0; pthread_t id[24]; for (i = 0; i <=23 ; i++) { int ret; ret = pthread_create(&id[i], NULL, (void*)thread_func, i); if (ret != 0) { printf("Create pthread error!\n"); return -1; } } // pthread_join for (i = 0; i <=23 ; i++) { pthread_join(id[i], NULL); } return 0;}
0 0
- 让机器所有的cpu核打满
- winlogon.exe 让机器CPU 100%
- 让GPU和CPU所有的核心都燃烧起来,…
- dump所有cpu的callstack
- linux机器的CPU过热
- 同步所有机器的收藏夹
- 吃掉所有CPU资源的 svchost.exe
- 32 位CPU的所有寄存器
- x86 CPU所有的寄存器种类
- CPU执行机器代码的过程
- linux 下查看机器cpu是几核的
- linux 下查看机器cpu是几核的
- linux 下查看机器cpu是几核的
- shell脚本消耗机器的CPU实例
- 机器cpu与内存配置的获取
- ubuntu下查看机器cpu是几核的
- linux 下查看机器cpu是几核的
- 查看windows机器的cpu信息
- java中的匿名内部类总结
- Java集合---ConcurrentHashMap原理分析
- 七牛---关于回调流程
- 在Windows下搭建React Native Android开发环境
- 15.4 CVPR 2015 papers
- 让机器所有的cpu核打满
- 特征向量的几何含义
- [TwistedFate]指针
- js解析XMl文件,兼容IE、Firefox、谷歌
- 编译opencv该注意的问题
- 带方向性全排列
- Block - 3
- 从头学Qt Quick(1) --体验快速构建动态效果界面
- 关于更新sdk用的代理设置,以及hosts配置的了解