1.sched_yield()中断当前进程让出处理器
int sched_yield (void);
2.设置进程优先级
int nice (int inc);
int getpriority (int which, int who);
int setpriority (int which, int who, int prio);
3.设置I/O优先级
int ioprio_get (int which, int who)
int ioprio_set (int which, int who, int ioprio)
4.设置获取处理器亲和度
#define _GNU_SOURCE
#include <sched.h>
typedef struct cpu_set_t;
size_t CPU_SETSIZE;
void CPU_SET (unsigned long cpu, cpu_set_t *set);
void CPU_CLR (unsigned long cpu, cpu_set_t *set);
int CPU_ISSET (unsigned long cpu, cpu_set_t *set);
void CPU_ZERO (cpu_set_t *set);
int sched_setaffinity (pid_t pid, size_t setsize,const cpu_set_t *set);
int sched_getaffinity (pid_t pid, size_t setsize,const cpu_set_t *set);
5.设置调度策略
#include <sched.h>
struct sched_param {
/* ... */
int sched_priority;
/* ... */
};
int sched_getscheduler (pid_t pid);
int sched_setscheduler (pid_t pid, int policy,const struct sched_param *sp);
6.设置调度策略参数
#include <sched.h>
struct sched_param {
/* ... */
int sched_priority;
/* ... */
};
int sched_getparam (pid_t pid, struct sched_param *sp);
int sched_setparam (pid_t pid, const struct sched_param *sp);
7.确定有效优先级范围
int sched_get_priority_min (int policy);
int sched_get_priority_max (int policy);
8.获取时间片长度
#include <sched.h>
struct timespec {
time_t tv_sec; /* seconds */
long /* nanoseconds */
tv_nsec;
};
int sched_rr_get_interval (pid_t pid, struct timespec *tp);
高级进程管理
最新推荐文章于 2022-10-04 09:18:59 发布