Add RUMPUSER_LWP_CLEAR instead of overloading RUMPUSER_LWP_SET.
This simplifies some alternative hypervisor implementations.
This commit is contained in:
parent
6c053402cc
commit
d0d5069c1a
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: rumpuser.3,v 1.9 2013/05/03 20:27:16 wiz Exp $
|
||||
.\" $NetBSD: rumpuser.3,v 1.10 2013/05/15 14:07:26 pooka Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2013 Antti Kantee. All rights reserved.
|
||||
.\"
|
||||
|
@ -23,7 +23,7 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd May 2, 2013
|
||||
.Dd May 15, 2013
|
||||
.Dt RUMPUSER 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -475,10 +475,14 @@ from the hypervisor.
|
|||
Set
|
||||
.Fa l
|
||||
as the current host thread's rump kernel context.
|
||||
The value
|
||||
.Dv NULL
|
||||
means that an existing rump kernel context (which must exist)
|
||||
must be cleared.
|
||||
A previous context must not exist.
|
||||
.It Dv RUMPUSER_LWP_CLEAR
|
||||
Clear the context previous set by
|
||||
.Dv RUMPUSER_LWP_SET .
|
||||
The value passed in
|
||||
.Fa l
|
||||
is the current thread and is never
|
||||
.Dv NULL.
|
||||
.El
|
||||
.Pp
|
||||
.Ft struct lwp *
|
||||
|
@ -641,7 +645,8 @@ Routines which do not return an integer may never fail.
|
|||
.%A Antti Kantee
|
||||
.%D 2012
|
||||
.%J Aalto University Doctoral Dissertations
|
||||
.%T Flexible Operating System Internals: The Design and Implementation of the Anykernel and Rump Kernerls
|
||||
.%T Flexible Operating System Internals: The Design and Implementation of the Anykernel and Rump Kernels
|
||||
.%O Section 2.3.2: The Hypercall Interface
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
The rump kernel hypercall API was first introduced in
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rumpuser_pth.c,v 1.28 2013/05/05 12:27:38 pooka Exp $ */
|
||||
/* $NetBSD: rumpuser_pth.c,v 1.29 2013/05/15 14:07:26 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
|
||||
|
@ -28,7 +28,7 @@
|
|||
#include "rumpuser_port.h"
|
||||
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: rumpuser_pth.c,v 1.28 2013/05/05 12:27:38 pooka Exp $");
|
||||
__RCSID("$NetBSD: rumpuser_pth.c,v 1.29 2013/05/15 14:07:26 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
@ -627,26 +627,27 @@ rumpuser_curlwpop(enum rumplwpop op, struct lwp *l)
|
|||
free(rl);
|
||||
break;
|
||||
case RUMPUSER_LWP_SET:
|
||||
assert(pthread_getspecific(curlwpkey) == NULL || l == NULL);
|
||||
assert(pthread_getspecific(curlwpkey) == NULL && l != NULL);
|
||||
|
||||
if (l) {
|
||||
pthread_mutex_lock(&lwplock);
|
||||
LIST_FOREACH(rl, &lwps, l_entries) {
|
||||
if (rl->l == l)
|
||||
break;
|
||||
}
|
||||
if (!rl) {
|
||||
fprintf(stderr,
|
||||
"LWP_SET: %p does not exist\n", l);
|
||||
abort();
|
||||
}
|
||||
pthread_mutex_unlock(&lwplock);
|
||||
} else {
|
||||
rl = NULL;
|
||||
pthread_mutex_lock(&lwplock);
|
||||
LIST_FOREACH(rl, &lwps, l_entries) {
|
||||
if (rl->l == l)
|
||||
break;
|
||||
}
|
||||
if (!rl) {
|
||||
fprintf(stderr,
|
||||
"LWP_SET: %p does not exist\n", l);
|
||||
abort();
|
||||
}
|
||||
pthread_mutex_unlock(&lwplock);
|
||||
|
||||
pthread_setspecific(curlwpkey, rl);
|
||||
break;
|
||||
case RUMPUSER_LWP_CLEAR:
|
||||
assert(((struct rumpuser_lwp *)
|
||||
pthread_getspecific(curlwpkey))->l == l);
|
||||
pthread_setspecific(curlwpkey, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,9 +672,13 @@ rumpuser_curlwpop(enum rumplwpop op, struct lwp *l)
|
|||
case RUMPUSER_LWP_DESTROY:
|
||||
break;
|
||||
case RUMPUSER_LWP_SET:
|
||||
assert(pthread_getspecific(curlwpkey) == NULL || l == NULL);
|
||||
assert(pthread_getspecific(curlwpkey) == NULL);
|
||||
pthread_setspecific(curlwpkey, l);
|
||||
break;
|
||||
case RUMPUSER_LWP_CLEAR:
|
||||
assert(pthread_getspecific(curlwpkey) == l);
|
||||
pthread_setspecific(curlwpkey, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rumpuser.h,v 1.103 2013/05/02 21:45:28 pooka Exp $ */
|
||||
/* $NetBSD: rumpuser.h,v 1.104 2013/05/15 14:07:26 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2013 Antti Kantee. All Rights Reserved.
|
||||
|
@ -164,7 +164,10 @@ int rumpuser_thread_create(void *(*f)(void *), void *, const char *, int,
|
|||
void rumpuser_thread_exit(void) __dead;
|
||||
int rumpuser_thread_join(void *);
|
||||
|
||||
enum rumplwpop { RUMPUSER_LWP_CREATE, RUMPUSER_LWP_DESTROY, RUMPUSER_LWP_SET };
|
||||
enum rumplwpop {
|
||||
RUMPUSER_LWP_CREATE, RUMPUSER_LWP_DESTROY,
|
||||
RUMPUSER_LWP_SET, RUMPUSER_LWP_CLEAR
|
||||
};
|
||||
void rumpuser_curlwpop(enum rumplwpop, struct lwp *);
|
||||
struct lwp *rumpuser_curlwp(void);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lwproc.c,v 1.22 2013/05/02 19:15:01 pooka Exp $ */
|
||||
/* $NetBSD: lwproc.c,v 1.23 2013/05/15 14:07:26 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.22 2013/05/02 19:15:01 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.23 2013/05/15 14:07:26 pooka Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/atomic.h>
|
||||
|
@ -352,7 +352,7 @@ rump_lwproc_switch(struct lwp *newlwp)
|
|||
fd_free();
|
||||
}
|
||||
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, l);
|
||||
|
||||
newlwp->l_cpu = newlwp->l_target_cpu = l->l_cpu;
|
||||
newlwp->l_mutex = l->l_mutex;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rump.c,v 1.268 2013/05/02 21:45:28 pooka Exp $ */
|
||||
/* $NetBSD: rump.c,v 1.269 2013/05/15 14:07:26 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.268 2013/05/02 21:45:28 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.269 2013/05/15 14:07:26 pooka Exp $");
|
||||
|
||||
#include <sys/systm.h>
|
||||
#define ELFSIZE ARCH_ELFSIZE
|
||||
|
@ -346,7 +346,7 @@ rump_init(void)
|
|||
|
||||
rump_scheduler_init(numcpu);
|
||||
/* revert temporary context and schedule a semireal context */
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, l);
|
||||
initproc = &proc0; /* borrow proc0 before we get initproc started */
|
||||
rump_schedule();
|
||||
bootlwp = curlwp;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scheduler.c,v 1.33 2013/05/02 19:15:01 pooka Exp $ */
|
||||
/* $NetBSD: scheduler.c,v 1.34 2013/05/15 14:07:26 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.33 2013/05/02 19:15:01 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.34 2013/05/15 14:07:26 pooka Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/atomic.h>
|
||||
|
@ -399,10 +399,10 @@ rump_unschedule()
|
|||
lwp0.l_mutex = &unruntime_lock;
|
||||
lwp0.l_pflag &= ~LP_RUNNING;
|
||||
lwp0rele();
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, &lwp0);
|
||||
|
||||
} else if (__predict_false(l->l_flag & LW_RUMP_CLEAR)) {
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_SET, NULL);
|
||||
rumpuser_curlwpop(RUMPUSER_LWP_CLEAR, l);
|
||||
l->l_flag &= ~LW_RUMP_CLEAR;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue