b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

fork 优先级_github fork_fork(5)

电脑杂谈  发布时间:2017-04-10 15:06:12  来源:网络整理

ps -p -P

看下吧:PRIO 标识进程的优先级,怎么样? 有没有世界观又一次被颠覆的感觉? 你不是告诉我进程优先级取范围是 0..139吗???

别急, 看下ps 到底是怎么得到进程的优先级的。

ps 是通过 cat /proc/<pid>/stat 获取到的,

对应kernel 里面的实现在 fs/proc/base.c 中,

static const struct pid_entry tgid_base_stuff[] = {

	INF("cmdline",    S_IRUGO, proc_pid_cmdline),
	ONE("stat",       S_IRUGO, proc_tgid_stat),

看下priority 是通过task_prio()获取的,

static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
			struct pid *pid, struct task_struct *task, int whole)
{

	/* scale priority and nice values from timeslices to -20..20 */
	/* to make it look like a "normal" Unix priority/nice value  */
	priority = task_prio(task);
	nice = task_nice(task);

看下task_prio()

/**
 * task_prio - return the priority value of a given task.
 * @p: the task in question.
 *
 * This is the priority value as seen by users in /proc.
 * RT tasks are offset by -200. Normal tasks are centered
 * around 0, value goes from -16 to +15.
 */
int task_prio(const struct task_struct *p)
{
	return p->prio - MAX_RT_PRIO;//ps 命令得到的priority 值是 p->prio - 100 得到的!!!
}

github fork_fork_fork 优先级

赶紧找到你熟悉的进程看看,有没有突然又相信本文开始提醒你坚持的世界观:

task_struct 中的成员变量 prio越小,进程的优先级越高。prio 的取范围为0..139。

USER PID PPID VSIZE RSS PRIO NICE RTPRI SCHED PCY WCHAN PC NAME

root 1 0 932 716 20 0 0 0 fg c0179270 00029eb4 S /init

root 2 0 0 0 -2 0 1 1 fg c00ba720 00000000 S kthreadd

root 3 2 0 0 20 0 0 0 fg c00a1e00 00000000 S ksoftirqd/0


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-40531-5.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 侯亚楠
      侯亚楠

      美国的最终目的就是把世界上所有的大国分割成小国

    每日福利
    热点图片
    拼命载入中...