让cpu稳定在66%

来源:互联网 发布:神知结局形象 编辑:程序博客网 时间:2024/06/05 18:33
#include <unistd.h>    
#include <stdlib.h> 
#include <stdio.h>
#include <time.h>
int main(){
int time_start;
int fulltime = 5000;//总时间
int runtime = 50;//运行时间
while(1){
time_start = clock();
while((clock()-time_start)<runtime){}
usleep(fulltime-runtime);
}
return 0;
}
阅读全文
0 0
原创粉丝点击