Linux System Programming note 6—— Adcanced Process Management
2014-06-06 09:19
393 查看
1. Yield the Processor
#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
#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
相关文章推荐
- Linux System Programming note 8 ——File and Directory Management
- Linux System Programming note 8 ——File and Directory Management
- Linux System Programming note 5—— Process Management
- Linux System Programming note 11 ——Time
- Linux System Programming note 7 —— Threading
- Linux System Programming note 9 ——Memory Management
- The Linux Programming Interface 12 System And Process Information 系统和进程信息
- Linux System Programming note 2 ——File I/O
- Linux System Programming note 10 —— Signal
- Linux System Programming note 4 —— Advanced File I/O
- Linux System Programming note 1
- Linux System Management
- Linux programming and system knowledge
- Python library for Linux process management - Stack Overflow
- Linux System Programming --Chapter Two
- linux 线程的绑定 PTHREAD_SCOPE_SYSTEM(绑定的)和PTHREAD_SCOPE_PROCESS(非绑定的)
- Linux kernel Process Management 2.1(amd64)——Creation and Switch
- Linux System Programming --Chapter Four
- linux-programming-note-6(基本进程间通信方法)
- linux system management