Linux System Programming note 6—— Adcanced Process Management
来源:互联网 发布:手机手柄软件 编辑:程序博客网 时间:2024/06/05 19:20
1. Yield the Processor
7. Settig the Linux scheduling policy
#include <sched.h>
int sched_yield(void);
Legal nice values range from -20 to 19 inclusive, with a default value of 0.
2.nice()
#incude <unistd.h>
int nice(int inc); // only root owned process can provide a negative value for inc to increase the priority, non-root process may only lower their priorities.
3. getpriority() and setpriority()
#include <sys/time.h>
#inclulde <sys/resource.h>
int getprioirty(int which, int who);
int setpriority(int which, int who, int prio);
which: PRIO_PROCESS, PRIO_PGRP, or PRIO_USER
4. I/O Priorities
int ioprio_get (int which, int who);
int ioprio_set (int which, int who, int ioprio);
5. sched_getaffinity() and sched_setaffinity()
#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, cpu_set_t *set);
6. Real time process's static priority from 1-99, unrelated to the nice value. For nomal applications. this priority is always 0.
7. Settig the Linux scheduling policy
#include <sched.h>
struct sched_param{
/ * ... * /
int sched_priority;
/* ... */
};
int sched_getcheduler(pid_t pid);
int sched_setscheduler(pid_t pid,
int policy,
const struct sched_param *sp);
8. Setting Scheduling Parameters
#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);
9. Determining the range of balid priorityes
#include <sched.h>
int sched_get_priority_min(int policy);
int shced_get_priority_max(int polcy);
10. sched_rr_get_interval()
#include <sched.h>
struct timespec {
time_t tv_sec;
long tv_nsec;
};
int sched_rr_get_interval(pid_t pid, struct timespec *tp);
11. Resource Limits
#include <sys/time.h>
#include <sys/resource.h>
struct rlimit {
rlim_t rlim_cur; /* soft limit */
rlim_t rlim_max; /* hard limit */
};
int getrlimit(int resource, struct slimit *rlim);
int setrlimit(int resource, const struct rlimit *rlim);
12. The Limits
RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_LOCKS, RLIMIT_MEMLOCK, RLMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_RTTIME, RLIMIT_RTPRIO, RLIMIT_SIGPENDING, RLIMIT_STACK
0 0
- Linux System Programming note 6—— Adcanced Process Management
- Linux System Programming note 5—— Process Management
- Linux System Programming note 9 ——Memory Management
- Linux System Programming note 8 ——File and Directory Management
- Linux kernel Process Management 3.1(overview)——Schedule System
- Linux System Programming note 2 ——File I/O
- Linux System Programming note 7 —— Threading
- Linux System Programming note 10 —— Signal
- Linux System Programming note 11 ——Time
- Linux System Programming:Memory Management
- Linux System Programming note 1
- Linux System Programming note 4 —— Advanced File I/O
- Linux Process Management
- Process management in Linux
- linux process management
- Scalable Process Management System (Hydra) Commands
- Linux System Management
- Linux kernel Process Management 2.1(amd64)——Creation and Switch
- JAVA设计模式-单例模式
- HDU2222 Keywords Search AC自动机裸题
- Qt4过渡至Qt5
- SQL语句中 select……on
- Linux 常用命令
- Linux System Programming note 6—— Adcanced Process Management
- Lucene 全文检索的基本原理-索引里面究竟存些什么
- 利用FTP进行两台电脑的文件传输
- Eclipse设置XML文件的自动格式化配置
- Lucene 全文检索的基本原理-如何创建索引
- 业务规则入门简介
- Linux System Programming note 7 —— Threading
- 3种异步网络编程模型整理
- 【机器学习实战之三】:C++实现K-均值(K-Means)聚类算法