- Allow creating timeshard kthreads. To be used to fix the RAIDframe

parity rewrite issue.
- Create kthreads in the SCHED_RR class by default, not SCHED_FIFO.
This commit is contained in:
ad 2009-01-29 22:00:26 +00:00
parent 12cbb1b52b
commit a9743c2461
3 changed files with 34 additions and 11 deletions

View File

@ -1,6 +1,6 @@
.\" $NetBSD: kthread.9,v 1.17 2008/04/30 13:10:58 martin Exp $
.\" $NetBSD: kthread.9,v 1.18 2009/01/29 22:00:26 ad Exp $
.\"
.\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
.\" Copyright (c) 2000, 2007, 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 22, 2007
.Dd January 27, 2009
.Dt KTHREAD 9
.Os
.Sh NAME
@ -84,6 +84,17 @@ running (unless explicitly dropped by the thread).
Specifies that the thread services device interrupts.
This flag is intended for kernel internal use and should not normally be
specified.
.Pp
.Dv KTHREAD_TS :
Causes the kthread to be created in the SCHED_OTHER class (timeshared).
The threads' priority will be dynamically adjusted by the scheduler.
Increased activity by the kthread will cause its priority to fall;
decreased activity will cause its priority to rise.
By default, kthreads are created in the SCHED_RR class, with a fixed
priority specified by
.Ar pri .
Threads in the SCHED_RR class do not have their priority dynamically
adjusted by the scheduler.
.It Fa ci
If non-NULL, the thread will be created bound to the CPU specified
by

View File

@ -1,7 +1,7 @@
/* $NetBSD: kern_kthread.c,v 1.24 2008/04/28 20:24:03 martin Exp $ */
/* $NetBSD: kern_kthread.c,v 1.25 2009/01/29 22:00:26 ad Exp $ */
/*-
* Copyright (c) 1998, 1999, 2007 The NetBSD Foundation, Inc.
* Copyright (c) 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.24 2008/04/28 20:24:03 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.25 2009/01/29 22:00:26 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -63,12 +63,18 @@ kthread_create(pri_t pri, int flag, struct cpu_info *ci,
bool inmem;
int error;
va_list ap;
int lc;
inmem = uvm_uarea_alloc(&uaddr);
if (uaddr == 0)
return ENOMEM;
if ((flags & KTHREAD_TS) != 0) {
lc = SCHED_OTHER;
} else {
lc = SCHED_RR;
}
error = lwp_create(&lwp0, &proc0, uaddr, inmem, LWP_DETACHED, NULL,
0, func, arg, &l, SCHED_FIFO);
0, func, arg, &l, lc);
if (error) {
uvm_uarea_free(uaddr, curcpu());
return error;
@ -93,8 +99,13 @@ kthread_create(pri_t pri, int flag, struct cpu_info *ci,
}
if (pri == PRI_NONE) {
/* Minimum kernel priority level. */
pri = PRI_KTHREAD;
if ((flags & KTHREAD_TS) != 0) {
/* Maximum user priority level. */
pri = MAXPRI_USER;
} else {
/* Minimum kernel priority level. */
pri = PRI_KTHREAD;
}
}
mutex_enter(proc0.p_lock);
lwp_lock(l);

View File

@ -1,7 +1,7 @@
/* $NetBSD: kthread.h,v 1.7 2008/04/28 20:24:10 martin Exp $ */
/* $NetBSD: kthread.h,v 1.8 2009/01/29 22:00:26 ad Exp $ */
/*-
* Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
* Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -43,6 +43,7 @@
#define KTHREAD_IDLE 0x01 /* do not set runnable */
#define KTHREAD_MPSAFE 0x02 /* does not need kernel_lock */
#define KTHREAD_INTR 0x04 /* interrupt handler */
#define KTHREAD_TS 0x08 /* timeshared */
int kthread_create(pri_t, int, struct cpu_info *,
void (*)(void *), void *,