进程的优先级设置与获取,进程时间
来源:互联网 发布:怪物猎人3捏脸数据库 编辑:程序博客网 时间:2024/06/03 06:30
进程的优先级设置与获取:值越小优先级越高
#include <sys/time.h>
#include <sys/resource.h>
int niece(int add)
int getpriority(int which, id_t who);
int setpriority(int which, id_t who, int prio);
which:
PRIO_PROCESS 进程
PRIO_PGRP 进程组
PRIO_USER 用户ID
#include <sys/time.h>
#include <sys/resource.h>
int niece(int add)
int getpriority(int which, id_t who);
int setpriority(int which, id_t who, int prio);
which:
PRIO_PROCESS 进程
PRIO_PGRP 进程组
PRIO_USER 用户ID
who: = 0
进程时间:
#include <sys/times.h>
clock_t times(struct tms *buf);
struct tms {
clock_t tms_utime; /* user time */
clock_t tms_stime; /* system time */
clock_t tms_cutime; /* user time of children */
clock_t tms_cstime; /* system time of children */
};
#include<sys/resource.h>#include<sys/times.h>void PocessPriorityTest(){ pid_t pid_1,pid_2; pid_1 = fork(); if(pid_1 ==0) { cout<<"pid_1 priority = "<<nice(0)<<endl; getpriority(PRIO_PROCESS,0); setpriority(PRIO_PROCESS,0,1); setpriority(PRIO_PROCESS,0,20); cout<<"pid_1 priority = "<<nice(0)<<endl; for(int i=0; i<4; i++) { cout<<"pid_1 "<<endl; sleep(1); } exit(1); } else { pid_2 = fork(); if(pid_2 ==0) { struct tms tmsstart ,tmsend; clock_t start = times(&tmsstart); cout<<"pid_2 priority = "<<nice(0)<<endl; for(int i=0; i<4; i++) { cout<<"pid_2 "<<endl; sleep(1); } clock_t ends = times(&tmsend); cout<<"time = "<<ends-start<<endl; exit(1); } waitpid(pid_1,NULL,0); waitpid(pid_2,NULL,0); cout<<"process end"<<endl; }}
0 0
- 进程的优先级设置与获取,进程时间
- 进程的优先级设置与获取,进程时间
- 进程优先级的设置
- 进程优先级获取和设置
- _high_priority_processes进程的优先级设置
- Android的进程优先级与进程回收
- Android的进程优先级与进程回收
- Android的进程优先级与进程回收
- 进程的生命周期与优先级
- VB设置进程优先级
- C# 设置进程优先级
- linux 进程优先级设置
- 设置当前进程优先级
- linux进程优先级设置
- nice设置进程优先级
- 进程优先级与后台进程
- Android的进程、线程与优先级
- AIX 上的进程优先级与进程控制
- 为什么你投不出阿里巴巴?这些大咖的分享你读了吗?
- adaboost训练 之 弱分类器训练原理
- RabbitMQ (五)主题(Topic)
- 获取屏幕宽度高度截图的工具类
- VC如何获取对话框中控件的坐标
- 进程的优先级设置与获取,进程时间
- 客户端工程的搭建
- 建立flask的虚拟环境
- 关闭酷狗右下角的弹窗
- 介绍Java中的内存泄漏
- Oracle 10g Audit(审计) --- 记录登录用户在Oracle中的所有操作
- OJ1069
- 摄像机标定--矫正畸变
- datatables动态添加隐藏行