Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/sys_sched.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/sys_sched.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.38 retrieving revision 1.38.2.3 diff -u -p -r1.38 -r1.38.2.3 --- src/sys/kern/sys_sched.c 2011/08/07 21:38:32 1.38 +++ src/sys/kern/sys_sched.c 2014/05/22 11:41:03 1.38.2.3 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_sched.c,v 1.38 2011/08/07 21:38:32 rmind Exp $ */ +/* $NetBSD: sys_sched.c,v 1.38.2.3 2014/05/22 11:41:03 yamt Exp $ */ /* * Copyright (c) 2008, 2011 Mindaugas Rasiukevicius @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.38 2011/08/07 21:38:32 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.38.2.3 2014/05/22 11:41:03 yamt Exp $"); #include @@ -53,8 +53,6 @@ __KERNEL_RCSID(0, "$NetBSD: sys_sched.c, #include #include #include -#include -#include #include #include #include @@ -62,8 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: sys_sched.c, #include #include -#include "opt_sa.h" - static struct sysctllog *sched_sysctl_log; static kauth_listener_t sched_listener; @@ -96,6 +92,11 @@ convert_pri(lwp_t *l, int policy, pri_t /* Real-time -> time-sharing */ if (policy == SCHED_OTHER) { KASSERT(l->l_class == SCHED_FIFO || l->l_class == SCHED_RR); + /* + * this is a bit arbitrary because the priority is dynamic + * for SCHED_OTHER threads and will likely be changed by + * the scheduler soon anyway. + */ return l->l_priority - PRI_USER_RT; } @@ -218,6 +219,11 @@ out: return error; } +/* + * do_sched_getparam: + * + * if lid=0, returns the parameter of the first LWP in the process. + */ int do_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params) @@ -226,8 +232,7 @@ do_sched_getparam(pid_t pid, lwpid_t lid struct lwp *t; int error, lpolicy; - /* Locks the LWP */ - t = lwp_find2(pid, lid); + t = lwp_find2(pid, lid); /* acquire p_lock */ if (t == NULL) return ESRCH; @@ -242,7 +247,17 @@ do_sched_getparam(pid_t pid, lwpid_t lid lwp_lock(t); lparams.sched_priority = t->l_priority; lpolicy = t->l_class; + lwp_unlock(t); + mutex_exit(t->l_proc->p_lock); + /* + * convert to the user-visible priority value. + * it's an inversion of convert_pri(). + * + * the SCHED_OTHER case is a bit arbitrary given that + * - we don't allow setting the priority. + * - the priority is dynamic. + */ switch (lpolicy) { case SCHED_OTHER: lparams.sched_priority -= PRI_USER; @@ -259,8 +274,6 @@ do_sched_getparam(pid_t pid, lwpid_t lid if (params != NULL) *params = lparams; - lwp_unlock(t); - mutex_exit(t->l_proc->p_lock); return error; } @@ -301,7 +314,7 @@ genkcpuset(kcpuset_t **dset, const cpuse kcpuset_t *kset; int error; - kcpuset_create(&kset, false); + kcpuset_create(&kset, true); error = kcpuset_copyin(sset, kset, size); if (error) { kcpuset_unuse(kset, NULL); @@ -353,8 +366,9 @@ sys__sched_setaffinity(struct lwp *l, for (CPU_INFO_FOREACH(cii, ici)) { struct schedstate_percpu *ispc; - if (kcpuset_isset(kcset, cpu_index(ici)) == 0) + if (!kcpuset_isset(kcset, cpu_index(ici))) { continue; + } ispc = &ici->ci_schedstate; /* Check that CPU is not in the processor-set */ @@ -416,15 +430,6 @@ sys__sched_setaffinity(struct lwp *l, goto out; } -#ifdef KERN_SA - /* Changing the affinity of a SA process is not supported */ - if ((p->p_sflag & (PS_SA | PS_WEXIT)) != 0 || p->p_sa != NULL) { - mutex_exit(p->p_lock); - error = EINVAL; - goto out; - } -#endif - /* Iterate through LWP(s). */ lcnt = 0; lid = SCARG(uap, lid); @@ -534,11 +539,6 @@ sys_sched_yield(struct lwp *l, const voi { yield(); -#ifdef KERN_SA - if (l->l_flag & LW_SA) { - sa_preempt(l); - } -#endif return 0; } @@ -551,11 +551,6 @@ sysctl_sched_setup(struct sysctllog **cl const struct sysctlnode *node = NULL; sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT, - CTLTYPE_NODE, "kern", NULL, - NULL, 0, NULL, 0, - CTL_KERN, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE, CTLTYPE_INT, "posix_sched", SYSCTL_DESCR("Version of IEEE Std 1003.1 and its "