Drop broken tests (no longer builds in years)
Removed: - callout1 - mutex1 - mutex2 - priority_inheritance1 - rwlock1 These tests used to require lkm code, that has been removed. Today they are implicitly mostly verified by rumpkernel tests in ATF.
This commit is contained in:
parent
e57d224cf0
commit
523f038f8a
@ -1,13 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.1 2008/03/28 20:44:57 ad Exp $
|
||||
|
||||
KMOD= callout1_test
|
||||
|
||||
NOMAN=
|
||||
|
||||
.PATH: ${.CURDIR}/../lkmcommon
|
||||
|
||||
SRCS= lkminit_test.c test_callout1.c
|
||||
CPPFLAGS+=-DLKMENTRY=callout1_test_lkmentry
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.subdir.mk>
|
@ -1,110 +0,0 @@
|
||||
/* $NetBSD: test_callout1.c,v 1.3 2008/04/28 20:23:06 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Doran.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: test_callout1.c,v 1.3 2008/04/28 20:23:06 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/callout.h>
|
||||
|
||||
int testcall(struct lwp *, void *, register_t *);
|
||||
|
||||
void test_callout(void *);
|
||||
void test_softint(void *);
|
||||
|
||||
kmutex_t test_mutex;
|
||||
kcondvar_t test_cv;
|
||||
int test_done;
|
||||
void *test_sih;
|
||||
callout_t test_ch;
|
||||
|
||||
void
|
||||
test_callout(void *cookie)
|
||||
{
|
||||
int s;
|
||||
|
||||
/* Trigger soft interrupt. */
|
||||
s = splhigh();
|
||||
softint_schedule(test_sih);
|
||||
splx(s);
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
test_done = 1;
|
||||
cv_broadcast(&test_cv);
|
||||
mutex_exit(&test_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
test_softint(void *cookie)
|
||||
{
|
||||
|
||||
printf("l_ncsw = %d\n", (int)curlwp->l_ncsw);
|
||||
callout_halt(&test_ch, NULL);
|
||||
printf("l_ncsw = %d\n", (int)curlwp->l_ncsw);
|
||||
}
|
||||
|
||||
int
|
||||
testcall(struct lwp *l, void *uap, register_t *retval)
|
||||
{
|
||||
|
||||
printf("test: initializing\n");
|
||||
|
||||
mutex_init(&test_mutex, MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&test_cv, "testcv");
|
||||
test_sih = softint_establish(SOFTINT_MPSAFE | SOFTINT_SERIAL,
|
||||
test_softint, NULL);
|
||||
callout_init(&test_ch, CALLOUT_MPSAFE);
|
||||
callout_setfunc(&test_ch, test_callout, NULL);
|
||||
|
||||
printf("test: firing\n");
|
||||
callout_schedule(&test_ch, hz / 10);
|
||||
|
||||
printf("test: waiting\n");
|
||||
mutex_enter(&test_mutex);
|
||||
while (!test_done) {
|
||||
cv_wait(&test_cv, &test_mutex);
|
||||
}
|
||||
mutex_exit(&test_mutex);
|
||||
|
||||
printf("test: finished\n");
|
||||
|
||||
callout_destroy(&test_ch);
|
||||
softint_disestablish(test_sih);
|
||||
mutex_destroy(&test_mutex);
|
||||
cv_destroy(&test_cv);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.3 2007/02/24 15:25:23 yamt Exp $
|
||||
|
||||
KMOD= mutex1_test
|
||||
|
||||
NOMAN=
|
||||
|
||||
.PATH: ${.CURDIR}/../lkmcommon
|
||||
|
||||
SRCS= lkminit_test.c test_mutex1.c
|
||||
CPPFLAGS+=-DLKMENTRY=mutex1_test_lkmentry
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.subdir.mk>
|
@ -1,178 +0,0 @@
|
||||
/* $NetBSD: test_mutex1.c,v 1.5 2008/04/28 20:23:07 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Doran.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: test_mutex1.c,v 1.5 2008/04/28 20:23:07 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#define NTHREADS 9
|
||||
#define SECONDS 60
|
||||
|
||||
int testcall(struct lwp *, void *, register_t *);
|
||||
void thread1(void *);
|
||||
void thread2(void *);
|
||||
void thread3(void *);
|
||||
void thread_exit(void);
|
||||
|
||||
lwp_t *test_threads[NTHREADS];
|
||||
kmutex_t test_mutex;
|
||||
kcondvar_t test_cv;
|
||||
int test_count;
|
||||
int test_exit;
|
||||
|
||||
void
|
||||
thread_exit(void)
|
||||
{
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
if (--test_count == 0)
|
||||
cv_signal(&test_cv);
|
||||
mutex_exit(&test_mutex);
|
||||
kthread_exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* test_mutex -> kernel_lock
|
||||
*/
|
||||
void
|
||||
thread1(void *cookie)
|
||||
{
|
||||
int count;
|
||||
|
||||
for (count = 0; !test_exit; count++) {
|
||||
mutex_enter(&test_mutex);
|
||||
KERNEL_LOCK(1, curlwp);
|
||||
if ((count % 11) == 0)
|
||||
yield();
|
||||
mutex_exit(&test_mutex);
|
||||
KERNEL_UNLOCK_ONE(curlwp);
|
||||
if ((count % 17) == 0)
|
||||
yield();
|
||||
}
|
||||
|
||||
thread_exit();
|
||||
}
|
||||
|
||||
/*
|
||||
* kernel_lock -> test_mutex
|
||||
*/
|
||||
void
|
||||
thread2(void *cookie)
|
||||
{
|
||||
int count;
|
||||
|
||||
for (count = 0; !test_exit; count++) {
|
||||
KERNEL_LOCK(1, curlwp);
|
||||
mutex_enter(&test_mutex);
|
||||
if ((count % 401) == 0)
|
||||
yield();
|
||||
KERNEL_UNLOCK_ONE(curlwp);
|
||||
mutex_exit(&test_mutex);
|
||||
if ((count % 19) == 0)
|
||||
yield();
|
||||
}
|
||||
|
||||
thread_exit();
|
||||
}
|
||||
|
||||
/*
|
||||
* test_mutex without kernel_lock, to provide pressure
|
||||
*/
|
||||
void
|
||||
thread3(void *cookie)
|
||||
{
|
||||
int count;
|
||||
|
||||
for (count = 0; !test_exit; count++) {
|
||||
mutex_enter(&test_mutex);
|
||||
DELAY(10);
|
||||
if ((count % 101) == 0)
|
||||
yield();
|
||||
mutex_exit(&test_mutex);
|
||||
if ((count % 23) == 0)
|
||||
yield();
|
||||
}
|
||||
|
||||
thread_exit();
|
||||
}
|
||||
|
||||
int
|
||||
testcall(struct lwp *l, void *uap, register_t *retval)
|
||||
{
|
||||
void (*func)(void *);
|
||||
int i;
|
||||
|
||||
mutex_init(&test_mutex, MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&test_cv, "testcv");
|
||||
|
||||
printf("test: creating threads\n");
|
||||
|
||||
test_count = NTHREADS;
|
||||
test_exit = 0;
|
||||
|
||||
for (i = 0; i < test_count; i++) {
|
||||
switch (i % 3) {
|
||||
case 0:
|
||||
func = thread1;
|
||||
break;
|
||||
case 1:
|
||||
func = thread2;
|
||||
break;
|
||||
case 2:
|
||||
func = thread3;
|
||||
break;
|
||||
}
|
||||
kthread_create(0, KTHREAD_MPSAFE, NULL, func, NULL,
|
||||
&test_threads[i], "thread%d", i);
|
||||
}
|
||||
|
||||
printf("test: sleeping\n");
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
while (test_count != 0) {
|
||||
(void)cv_timedwait(&test_cv, &test_mutex, hz * SECONDS);
|
||||
test_exit = NTHREADS;
|
||||
}
|
||||
mutex_exit(&test_mutex);
|
||||
|
||||
printf("test: finished\n");
|
||||
|
||||
cv_destroy(&test_cv);
|
||||
mutex_destroy(&test_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.2 2007/02/24 15:25:24 yamt Exp $
|
||||
|
||||
KMOD= mutex2_test
|
||||
|
||||
NOMAN=
|
||||
|
||||
.PATH: ${.CURDIR}/../lkmcommon
|
||||
|
||||
SRCS= lkminit_test.c test_mutex2.c
|
||||
CPPFLAGS+=-DLKMENTRY=mutex2_test_lkmentry
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.subdir.mk>
|
@ -1,124 +0,0 @@
|
||||
/* $NetBSD: test_mutex2.c,v 1.5 2008/04/28 20:23:07 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Doran.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: test_mutex2.c,v 1.5 2008/04/28 20:23:07 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#define NTHREADS 32
|
||||
#define SECONDS 60
|
||||
|
||||
int testcall(struct lwp *, void *, register_t *);
|
||||
void thread1(void *);
|
||||
void thread_enter(void);
|
||||
|
||||
lwp_t *test_threads[NTHREADS];
|
||||
kmutex_t test_mutex;
|
||||
kcondvar_t test_cv;
|
||||
int test_count;
|
||||
int test_exit;
|
||||
|
||||
static int primes[NTHREADS] = {
|
||||
131, 137, 139, 149,
|
||||
151, 157, 163, 167,
|
||||
173, 179, 181, 191,
|
||||
193, 197, 199, 211,
|
||||
223, 227, 229, 233,
|
||||
239, 241, 251, 257,
|
||||
263, 269, 271, 277,
|
||||
281, 283, 293, 307,
|
||||
};
|
||||
|
||||
void
|
||||
thread_exit(void)
|
||||
{
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
if (--test_count == 0)
|
||||
cv_signal(&test_cv);
|
||||
mutex_exit(&test_mutex);
|
||||
kthread_exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
thread1(void *cookie)
|
||||
{
|
||||
int count;
|
||||
|
||||
for (count = 0; !test_exit; count++) {
|
||||
mutex_enter(&test_mutex);
|
||||
if ((count % *(int *)cookie) == 0)
|
||||
yield();
|
||||
mutex_exit(&test_mutex);
|
||||
if ((count % curproc->p_pid) == 0)
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
testcall(struct lwp *l, void *uap, register_t *retval)
|
||||
{
|
||||
int i;
|
||||
|
||||
mutex_init(&test_mutex, MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&test_cv, "testcv");
|
||||
|
||||
printf("test: creating threads\n");
|
||||
|
||||
test_count = NTHREADS;
|
||||
test_exit = 0;
|
||||
|
||||
for (i = 0; i < test_count; i++)
|
||||
kthread_create(0, KTHREAD_MPSAFE, NULL, thread1, &primes[i],
|
||||
&test_threads[i], "thread%d", i);
|
||||
|
||||
printf("test: sleeping\n");
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
while (test_count != 0) {
|
||||
(void)cv_timedwait(&test_cv, &test_mutex, hz * SECONDS);
|
||||
test_exit = 1;
|
||||
}
|
||||
mutex_exit(&test_mutex);
|
||||
|
||||
printf("test: finished\n");
|
||||
|
||||
cv_destroy(&test_cv);
|
||||
mutex_destroy(&test_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.1 2007/02/25 09:52:47 yamt Exp $
|
||||
|
||||
KMOD= priority_inheritance1_test
|
||||
|
||||
NOMAN=
|
||||
|
||||
.PATH: ${.CURDIR}/../lkmcommon
|
||||
|
||||
SRCS= lkminit_test.c test_priority_inheritance1.c
|
||||
CPPFLAGS+=-DLKMENTRY=priority_inheritance1_test_lkmentry
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.subdir.mk>
|
@ -1,228 +0,0 @@
|
||||
/* $NetBSD: test_priority_inheritance1.c,v 1.2 2008/04/28 20:23:07 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Doran.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: test_priority_inheritance1.c,v 1.2 2008/04/28 20:23:07 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#define SECONDS 5
|
||||
|
||||
int testcall(struct lwp *, void *, register_t *);
|
||||
void dummy(void *);
|
||||
void lowprio(void *);
|
||||
void highprio(void *);
|
||||
void thread_exit(int, int);
|
||||
void thread_enter(int *, int);
|
||||
|
||||
kmutex_t test_mutex;
|
||||
kcondvar_t test_cv;
|
||||
bool test_exit;
|
||||
|
||||
int started;
|
||||
kcondvar_t start_cv;
|
||||
int exited;
|
||||
kcondvar_t exit_cv;
|
||||
|
||||
void
|
||||
changepri(int prio)
|
||||
{
|
||||
struct lwp *l = curlwp;
|
||||
|
||||
lwp_lock(l);
|
||||
lwp_changepri(l, prio);
|
||||
lwp_unlock(l);
|
||||
}
|
||||
|
||||
void
|
||||
printpri(const char *msg)
|
||||
{
|
||||
struct lwp *l = curlwp;
|
||||
|
||||
#if 0
|
||||
printf("%s: %s: eprio=%d l_priority=%d l_usrpri=%d\n",
|
||||
l->l_proc->p_comm, msg, lwp_eprio(l), l->l_priority, l->l_usrpri);
|
||||
#else
|
||||
printf("%s: %s: l_priority=%d l_usrpri=%d\n",
|
||||
l->l_proc->p_comm, msg, l->l_priority, l->l_usrpri);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
thread_enter(int *nlocks, int prio)
|
||||
{
|
||||
struct lwp *l = curlwp;
|
||||
|
||||
KERNEL_UNLOCK_ALL(l, nlocks);
|
||||
changepri(prio);
|
||||
yield(); /* XXX */
|
||||
printpri("enter");
|
||||
}
|
||||
|
||||
void
|
||||
thread_exit(int nlocks, int prio)
|
||||
{
|
||||
struct lwp *l = curlwp;
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
exited++;
|
||||
cv_signal(&exit_cv);
|
||||
mutex_exit(&test_mutex);
|
||||
|
||||
#if 0
|
||||
if (lwp_eprio(l) != prio)
|
||||
#else
|
||||
if (l->l_priority != prio || l->l_usrpri != prio)
|
||||
#endif
|
||||
printpri("ERROR: priority changed");
|
||||
|
||||
printpri("exit");
|
||||
|
||||
KERNEL_LOCK(nlocks, curlwp);
|
||||
kthread_exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
dummy(void *cookie)
|
||||
{
|
||||
int count, nlocks;
|
||||
int prio = (int)cookie;
|
||||
|
||||
thread_enter(&nlocks, prio);
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
started++;
|
||||
cv_signal(&start_cv);
|
||||
mutex_exit(&test_mutex);
|
||||
while (!test_exit)
|
||||
yield();
|
||||
|
||||
thread_exit(nlocks, prio);
|
||||
}
|
||||
|
||||
void
|
||||
lowprio(void *cookie)
|
||||
{
|
||||
struct lwp *l = curlwp;
|
||||
int count, nlocks;
|
||||
int prio = (int)cookie;
|
||||
|
||||
thread_enter(&nlocks, prio);
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
started++;
|
||||
cv_signal(&start_cv);
|
||||
|
||||
changepri(PUSER-1);
|
||||
kpause("test", false, hz, NULL);
|
||||
|
||||
printpri("have mutex");
|
||||
mutex_exit(&test_mutex);
|
||||
printpri("released mutex");
|
||||
|
||||
thread_exit(nlocks, PUSER-1);
|
||||
}
|
||||
|
||||
void
|
||||
highprio(void *cookie)
|
||||
{
|
||||
int count, nlocks;
|
||||
int prio = (int)cookie;
|
||||
|
||||
thread_enter(&nlocks, prio);
|
||||
|
||||
printf("highprio start\n");
|
||||
mutex_enter(&test_mutex);
|
||||
while (started < ncpu + 1)
|
||||
cv_wait(&start_cv, &test_mutex);
|
||||
mutex_exit(&test_mutex);
|
||||
printf("highprio done\n");
|
||||
|
||||
test_exit = true;
|
||||
|
||||
thread_exit(nlocks, prio);
|
||||
}
|
||||
|
||||
int
|
||||
testcall(struct lwp *l, void *uap, register_t *retval)
|
||||
{
|
||||
void (*func)(void *);
|
||||
int i;
|
||||
|
||||
mutex_init(&test_mutex, MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&start_cv, "startcv");
|
||||
cv_init(&exit_cv, "exitcv");
|
||||
cv_init(&test_cv, "testcv");
|
||||
|
||||
printf("test: creating threads\n");
|
||||
|
||||
test_exit = false;
|
||||
started = exited = 0;
|
||||
|
||||
changepri(PUSER-30);
|
||||
|
||||
for (i = 0; i < ncpu; i++)
|
||||
kthread_create1(dummy, (void *)(PUSER-10), NULL, "dummy-%d", i);
|
||||
mutex_enter(&test_mutex);
|
||||
while (started < ncpu)
|
||||
cv_wait(&start_cv, &test_mutex);
|
||||
mutex_exit(&test_mutex);
|
||||
|
||||
kthread_create1(lowprio, (void *)(PUSER-20), NULL, "lowprio");
|
||||
i++;
|
||||
kthread_create1(highprio, (void *)(PUSER-20), NULL, "highprio");
|
||||
i++;
|
||||
|
||||
printf("test: sleeping\n");
|
||||
kpause("test", false, hz * SECONDS, NULL);
|
||||
printf("test: woken\n");
|
||||
|
||||
if (!test_exit)
|
||||
printf("test: FAIL\n");
|
||||
test_exit = true;
|
||||
mutex_enter(&test_mutex);
|
||||
while (exited != i) {
|
||||
cv_wait(&exit_cv, &test_mutex);
|
||||
}
|
||||
mutex_exit(&test_mutex);
|
||||
|
||||
printf("test: finished\n");
|
||||
|
||||
cv_destroy(&test_cv);
|
||||
mutex_destroy(&test_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.2 2007/02/24 15:25:24 yamt Exp $
|
||||
|
||||
KMOD= rwlock1_test
|
||||
|
||||
NOMAN=
|
||||
|
||||
.PATH: ${.CURDIR}/../lkmcommon
|
||||
|
||||
SRCS= lkminit_test.c test_rwlock1.c
|
||||
CPPFLAGS+=-DLKMENTRY=rwlock1_test_lkmentry
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.subdir.mk>
|
@ -1,134 +0,0 @@
|
||||
/* $NetBSD: test_rwlock1.c,v 1.6 2008/04/28 20:23:07 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Doran.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: test_rwlock1.c,v 1.6 2008/04/28 20:23:07 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#define NTHREADS 32
|
||||
#define SECONDS 60
|
||||
|
||||
int testcall(struct lwp *, void *, register_t *);
|
||||
void thread1(void *);
|
||||
void thread_exit(void);
|
||||
|
||||
lwp_t *test_threads[NTHREADS];
|
||||
kmutex_t test_mutex;
|
||||
krwlock_t test_rwlock;
|
||||
kcondvar_t test_cv;
|
||||
int test_count;
|
||||
int test_exit;
|
||||
|
||||
static int primes[NTHREADS] = {
|
||||
17, 19, 23, 29,
|
||||
31, 37, 41, 43,
|
||||
47, 53, 59, 61,
|
||||
67, 71, 73, 79,
|
||||
83, 89, 97, 101,
|
||||
103, 107, 109, 113,
|
||||
127, 131, 137, 139,
|
||||
149, 151, 157, 163,
|
||||
};
|
||||
|
||||
void
|
||||
thread_exit(void)
|
||||
{
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
if (--test_count == 0)
|
||||
cv_signal(&test_cv);
|
||||
mutex_exit(&test_mutex);
|
||||
kthread_exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
thread1(void *cookie)
|
||||
{
|
||||
int count;
|
||||
krw_t op;
|
||||
|
||||
for (count = 0; !test_exit; count++) {
|
||||
if (count % *(int *)cookie == 0)
|
||||
op = RW_WRITER;
|
||||
else
|
||||
op = RW_READER;
|
||||
rw_enter(&test_rwlock, op);
|
||||
if ((arc4random() % 11) == 0)
|
||||
yield();
|
||||
rw_exit(&test_rwlock);
|
||||
if ((arc4random() % 23) == 0)
|
||||
yield();
|
||||
}
|
||||
|
||||
thread_exit();
|
||||
}
|
||||
|
||||
int
|
||||
testcall(struct lwp *l, void *uap, register_t *retval)
|
||||
{
|
||||
int i;
|
||||
|
||||
mutex_init(&test_mutex, MUTEX_DEFAULT, IPL_NONE);
|
||||
rw_init(&test_rwlock);
|
||||
cv_init(&test_cv, "testcv");
|
||||
|
||||
printf("test: creating threads\n");
|
||||
|
||||
test_count = NTHREADS;
|
||||
test_exit = 0;
|
||||
|
||||
for (i = 0; i < test_count; i++)
|
||||
kthread_create(0, KTHREAD_MPSAFE, NULL, thread1, &primes[i],
|
||||
&test_threads[i], "thread%d", i);
|
||||
|
||||
printf("test: sleeping\n");
|
||||
|
||||
mutex_enter(&test_mutex);
|
||||
while (test_count != 0) {
|
||||
(void)cv_timedwait(&test_cv, &test_mutex, hz * SECONDS);
|
||||
test_exit = 1;
|
||||
}
|
||||
mutex_exit(&test_mutex);
|
||||
|
||||
printf("test: finished\n");
|
||||
|
||||
cv_destroy(&test_cv);
|
||||
rw_destroy(&test_rwlock);
|
||||
mutex_destroy(&test_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user