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

fork 优先级_github fork_fork(4)

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

遍历整个kernel 代码树,只有三个地方会对p->static进行赋,

--------------------------

void sched_fork(struct task_struct *p)
{
	/*
	 * Revert to default priority/policy on fork if requested.
	 */
	if (unlikely(p->sched_reset_on_fork)) {
		if (task_has_rt_policy(p)) {
			p->policy = SCHED_NORMAL;
			p->static_prio = NICE_TO_PRIO(0);
			p->rt_priority = 0;
		} else if (PRIO_TO_NICE(p->static_prio) < 0)
			p->static_prio = NICE_TO_PRIO(0);

--------------------------

void set_user_nice(struct task_struct *p, long nice)
{

	/*
	 * The RT priorities are set via sched_setscheduler(), but we still
	 * allow the normal nice value to be set - but as expected
	 * it wont have any effect on scheng until the task is
	 * SCHED_FIFO/SCHED_RR:
	 */
	if (task_has_rt_policy(p)) {
		p->static_prio = NICE_TO_PRIO(nice);
		goto out_unlock;
	}
	on_rq = p->on_rq;
	if (on_rq)
		dequeue_task(rq, p, 0);

	p->static_prio = NICE_TO_PRIO(nice);
--------------------------

/*
 *  INIT_TASK is used to set up the first task table, touch at
 * your own risk!. Base=0, limit=0x1fffff (=2MB)
 */
#define INIT_TASK(tsk)	\
{									\
	.state		= 0,						\
	.stack		= &init_thread_info,				\
	.usage		= ATOMIC_INIT(2),				\
	.flags		= PF_KTHREAD,					\
	.prio		= MAX_PRIO-20,					\
	.static_prio	= MAX_PRIO-20,

明白了吧? p->static 的,也就是非实时进程的优先级只能通过fork 或是设置nice 间接修改。fork 优先级

接下来,你可能最关心的问题就是如何查看一个进程的优先级呢?

ps 提供这个选项,Android ps 的实现不同于ubuntu,看下system/core/toolbox/ps.c,源代码告诉我们选项足够了,调度策略,优先级,RT优先级都能看,


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

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

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