It seems profiling really really doesn't like pthreads on my system

for some reason.  Because I don't have time to descends into the
depths to figure out why, give an alternative rumpuser_pth module,
which allows to link rump completely without pthreads.  Naturally,
this means that no threads can be used, but it's enough to get
profiling done in some cases.
This commit is contained in:
pooka 2009-01-20 21:43:13 +00:00
parent ce80665a62
commit 8e9ecb1ac9
2 changed files with 323 additions and 2 deletions

View File

@ -1,10 +1,16 @@
# $NetBSD: Makefile,v 1.13 2009/01/05 21:42:37 pooka Exp $
# $NetBSD: Makefile,v 1.14 2009/01/20 21:43:13 pooka Exp $
#
LIB= rumpuser
WARNS= 4
SRCS= rumpuser.c rumpuser_net.c rumpuser_pth.c
SRCS= rumpuser.c rumpuser_net.c
SRCS+= rumpuser_pth.c
# Using this instead of the above makes it possible to link rump
# without involving pthreads. Multithreaded operation will not
# of course work correctly in case.
#SRCS+= rumpuser_pth_dummy.c
# no shlib_version because this is automatically in sync with lib/librumpuser
SHLIB_MAJOR= 0

View File

@ -0,0 +1,315 @@
/* $NetBSD: rumpuser_pth_dummy.c,v 1.1 2009/01/20 21:43:13 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
*
* 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 AUTHOR ``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 AUTHOR 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>
#if !defined(lint)
__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.1 2009/01/20 21:43:13 pooka Exp $");
#endif /* !lint */
#include <sys/time.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <rump/rumpuser.h>
#include "rumpuser_int.h"
struct rumpuser_cv {};
struct rumpuser_mtx {
int v;
};
struct rumpuser_rw {
int v;
};
struct rumpuser_mtx rumpuser_aio_mtx;
struct rumpuser_cv rumpuser_aio_cv;
int rumpuser_aio_head, rumpuser_aio_tail;
struct rumpuser_aio *rumpuser_aios[N_AIOS];
struct rumpuser_rw rumpspl;
void donada(int);
void donada(int arg) {}
void dounnada(int, int *);
void dounnada(int arg, int *ap) {}
kernel_lockfn rumpuser__klock = donada;
kernel_unlockfn rumpuser__kunlock = dounnada;
/*ARGSUSED*/
void
rumpuser_thrinit(kernel_lockfn lockfn, kernel_unlockfn unlockfn, int threads)
{
}
/*ARGSUSED*/
int
rumpuser_bioinit(rump_biodone_fn biodone)
{
return 0;
}
/*ARGSUSED*/
int
rumpuser_thread_create(void *(*f)(void *), void *arg, const char *thrname)
{
abort();
return 0;
}
void
rumpuser_thread_exit()
{
}
void
rumpuser_mutex_init(struct rumpuser_mtx **mtx)
{
*mtx = calloc(1, sizeof(struct rumpuser_mtx));
}
void
rumpuser_mutex_recursive_init(struct rumpuser_mtx **mtx)
{
rumpuser_mutex_init(mtx);
}
void
rumpuser_mutex_enter(struct rumpuser_mtx *mtx)
{
mtx->v++;
}
int
rumpuser_mutex_tryenter(struct rumpuser_mtx *mtx)
{
mtx->v++;
return 1;
}
void
rumpuser_mutex_exit(struct rumpuser_mtx *mtx)
{
mtx->v--;
}
void
rumpuser_mutex_destroy(struct rumpuser_mtx *mtx)
{
free(mtx);
}
int
rumpuser_mutex_held(struct rumpuser_mtx *mtx)
{
return mtx->v;
}
void
rumpuser_rw_init(struct rumpuser_rw **rw)
{
*rw = calloc(1, sizeof(struct rumpuser_rw));
}
void
rumpuser_rw_enter(struct rumpuser_rw *rw, int write)
{
if (write) {
rw->v++;
} else {
assert(rw->v <= 0);
rw->v--;
}
}
int
rumpuser_rw_tryenter(struct rumpuser_rw *rw, int write)
{
rumpuser_rw_enter(rw, write);
return 1;
}
void
rumpuser_rw_exit(struct rumpuser_rw *rw)
{
if (rw->v > 0) {
assert(rw->v == 1);
rw->v--;
} else {
rw->v++;
}
}
void
rumpuser_rw_destroy(struct rumpuser_rw *rw)
{
free(rw);
}
int
rumpuser_rw_held(struct rumpuser_rw *rw)
{
return rw->v != 0;
}
int
rumpuser_rw_rdheld(struct rumpuser_rw *rw)
{
return rw->v < 0;
}
int
rumpuser_rw_wrheld(struct rumpuser_rw *rw)
{
return rw->v > 0;
}
/*ARGSUSED*/
void
rumpuser_cv_init(struct rumpuser_cv **cv)
{
}
/*ARGSUSED*/
void
rumpuser_cv_destroy(struct rumpuser_cv *cv)
{
}
/*ARGSUSED*/
void
rumpuser_cv_wait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx)
{
}
/*ARGSUSED*/
int
rumpuser_cv_timedwait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx,
int stdticks)
{
struct timespec ts;
ts.tv_sec = stdticks / 100;
ts.tv_nsec = (stdticks % 100) * 10000000;
ts.tv_sec += ts.tv_nsec / 1000000000;
ts.tv_nsec %= 1000000000;
nanosleep(&ts, NULL);
return 0;
}
/*ARGSUSED*/
void
rumpuser_cv_signal(struct rumpuser_cv *cv)
{
}
/*ARGSUSED*/
void
rumpuser_cv_broadcast(struct rumpuser_cv *cv)
{
}
/*ARGSUSED*/
int
rumpuser_cv_has_waiters(struct rumpuser_cv *cv)
{
return 0;
}
/*
* curlwp
*/
static struct lwp *curlwp;
void
rumpuser_set_curlwp(struct lwp *l)
{
curlwp = l;
}
struct lwp *
rumpuser_get_curlwp()
{
return curlwp;
}
/*ARGSUSED*/
void
rumpuser_set_ipl(int what)
{
}
/*ARGSUSED*/
int
rumpuser_whatis_ipl()
{
return 0;
}
/*ARGSUSED*/
void
rumpuser_clear_ipl(int what)
{
}