Sat Oct 18 19:24:04 2008 UTC ()
Obviously intention was to check for SCHED_OTHER, not SCHED_FIFO.


(rmind)
diff -r1.29 -r1.30 src/sys/kern/sys_sched.c

cvs diff -r1.29 -r1.30 src/sys/kern/sys_sched.c (expand / switch to unified diff)

--- src/sys/kern/sys_sched.c 2008/10/18 03:40:18 1.29
+++ src/sys/kern/sys_sched.c 2008/10/18 19:24:04 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sys_sched.c,v 1.29 2008/10/18 03:40:18 rmind Exp $ */ 1/* $NetBSD: sys_sched.c,v 1.30 2008/10/18 19:24:04 rmind Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org> 4 * Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org>
5 * All rights reserved. 5 * All rights reserved.
6 *  6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * System calls relating to the scheduler. 30 * System calls relating to the scheduler.
31 * 31 *
32 * TODO: 32 * TODO:
33 * - Handle pthread_setschedprio() as defined by POSIX; 33 * - Handle pthread_setschedprio() as defined by POSIX;
34 * - Handle sched_yield() case for SCHED_FIFO as defined by POSIX; 34 * - Handle sched_yield() case for SCHED_FIFO as defined by POSIX;
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.29 2008/10/18 03:40:18 rmind Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.30 2008/10/18 19:24:04 rmind Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41 41
42#include <sys/cpu.h> 42#include <sys/cpu.h>
43#include <sys/kauth.h> 43#include <sys/kauth.h>
44#include <sys/kmem.h> 44#include <sys/kmem.h>
45#include <sys/lwp.h> 45#include <sys/lwp.h>
46#include <sys/mutex.h> 46#include <sys/mutex.h>
47#include <sys/proc.h> 47#include <sys/proc.h>
48#include <sys/pset.h> 48#include <sys/pset.h>
49#include <sys/sa.h> 49#include <sys/sa.h>
50#include <sys/savar.h> 50#include <sys/savar.h>
51#include <sys/sched.h> 51#include <sys/sched.h>
@@ -144,27 +144,27 @@ do_sched_setparam(pid_t pid, lwpid_t lid @@ -144,27 +144,27 @@ do_sched_setparam(pid_t pid, lwpid_t lid
144 lcnt = 0; 144 lcnt = 0;
145 LIST_FOREACH(t, &p->p_lwps, l_sibling) { 145 LIST_FOREACH(t, &p->p_lwps, l_sibling) {
146 pri_t kpri; 146 pri_t kpri;
147 int lpolicy; 147 int lpolicy;
148 148
149 if (lid && lid != t->l_lid) 149 if (lid && lid != t->l_lid)
150 continue; 150 continue;
151 151
152 lcnt++; 152 lcnt++;
153 lwp_lock(t); 153 lwp_lock(t);
154 lpolicy = (policy == SCHED_NONE) ? t->l_class : policy; 154 lpolicy = (policy == SCHED_NONE) ? t->l_class : policy;
155 155
156 /* Disallow setting of priority for SCHED_OTHER threads */ 156 /* Disallow setting of priority for SCHED_OTHER threads */
157 if (lpolicy == SCHED_FIFO && pri != PRI_NONE) { 157 if (lpolicy == SCHED_OTHER && pri != PRI_NONE) {
158 lwp_unlock(t); 158 lwp_unlock(t);
159 error = EINVAL; 159 error = EINVAL;
160 break; 160 break;
161 } 161 }
162 162
163 /* Convert priority, if needed */ 163 /* Convert priority, if needed */
164 kpri = convert_pri(t, lpolicy, pri); 164 kpri = convert_pri(t, lpolicy, pri);
165 165
166 /* Check the permission */ 166 /* Check the permission */
167 error = kauth_authorize_process(kauth_cred_get(), 167 error = kauth_authorize_process(kauth_cred_get(),
168 KAUTH_PROCESS_SCHEDULER_SETPARAM, p, t, KAUTH_ARG(lpolicy), 168 KAUTH_PROCESS_SCHEDULER_SETPARAM, p, t, KAUTH_ARG(lpolicy),
169 KAUTH_ARG(kpri)); 169 KAUTH_ARG(kpri));
170 if (error) { 170 if (error) {