Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumpuser Support multithreaded clients and fix a few ...
details: https://anonhg.NetBSD.org/src/rev/6a53adf49c7e
branches: trunk
changeset: 758887:6a53adf49c7e
user: pooka <pooka%NetBSD.org@localhost>
date: Fri Nov 19 17:09:44 2010 +0000
description:
Support multithreaded clients and fix a few bugs.
diffstat:
lib/librumpuser/rumpuser_sp.c | 37 +++++++++++++++++++++++++++++++------
lib/librumpuser/sp_common.c | 10 +++++-----
2 files changed, 36 insertions(+), 11 deletions(-)
diffs (135 lines):
diff -r 46f9ac94f1ef -r 6a53adf49c7e lib/librumpuser/rumpuser_sp.c
--- a/lib/librumpuser/rumpuser_sp.c Fri Nov 19 17:06:56 2010 +0000
+++ b/lib/librumpuser/rumpuser_sp.c Fri Nov 19 17:09:44 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_sp.c,v 1.7 2010/11/19 15:25:49 pooka Exp $ */
+/* $NetBSD: rumpuser_sp.c,v 1.8 2010/11/19 17:09:44 pooka Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.7 2010/11/19 15:25:49 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.8 2010/11/19 17:09:44 pooka Exp $");
#include <sys/types.h>
#include <sys/mman.h>
@@ -107,6 +107,18 @@
return rv;
}
+static int
+lwproc_newlwp(pid_t pid)
+{
+ int rv;
+
+ spops.spop_schedule();
+ rv = spops.spop_lwproc_newlwp(pid);
+ spops.spop_unschedule();
+
+ return rv;
+}
+
static struct lwp *
lwproc_curlwp(void)
{
@@ -119,6 +131,18 @@
return l;
}
+static pid_t
+lwproc_getpid(void)
+{
+ pid_t p;
+
+ spops.spop_schedule();
+ p = spops.spop_getpid();
+ spops.spop_unschedule();
+
+ return p;
+}
+
static int
rumpsyscall(int sysnum, void *data, register_t *retval)
{
@@ -271,7 +295,7 @@
DPRINTF(("rump_sp: disconnecting [%u]\n", idx));
- lwproc_switch(spc->spc_lwp);
+ lwproc_switch(spc->spc_mainlwp);
lwproc_release();
pthread_mutex_destroy(&spc->spc_mtx);
@@ -342,8 +366,9 @@
pfdlist[i].fd = newfd;
spclist[i].spc_fd = newfd;
- spclist[i].spc_lwp = lwproc_curlwp();
+ spclist[i].spc_mainlwp = lwproc_curlwp();
spclist[i].spc_istatus = SPCSTATUS_BUSY; /* dedicated receiver */
+ spclist[i].spc_pid = lwproc_getpid();
TAILQ_INIT(&spclist[i].spc_respwait);
pthread_mutex_init(&spclist[i].spc_mtx, NULL);
@@ -353,7 +378,7 @@
maxidx = i;
DPRINTF(("rump_sp: added new connection at idx %u, pid %d\n",
- i, 9)); /* XXX: getpid not spop */
+ i, lwproc_getpid()));
lwproc_switch(NULL);
@@ -371,7 +396,7 @@
sysnum, 0));
pthread_setspecific(spclient_tls, spc);
- lwproc_switch(spc->spc_lwp);
+ lwproc_newlwp(spc->spc_pid);
rv = rumpsyscall(sysnum, data, retval);
lwproc_switch(NULL);
pthread_setspecific(spclient_tls, NULL);
diff -r 46f9ac94f1ef -r 6a53adf49c7e lib/librumpuser/sp_common.c
--- a/lib/librumpuser/sp_common.c Fri Nov 19 17:06:56 2010 +0000
+++ b/lib/librumpuser/sp_common.c Fri Nov 19 17:09:44 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sp_common.c,v 1.5 2010/11/19 15:40:55 pooka Exp $ */
+/* $NetBSD: sp_common.c,v 1.6 2010/11/19 17:09:44 pooka Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -117,7 +117,9 @@
struct spclient {
int spc_fd;
- struct lwp *spc_lwp;
+
+ struct lwp *spc_mainlwp;
+ pid_t spc_pid;
/* incoming */
struct rsp_hdr spc_hdr;
@@ -226,11 +228,10 @@
}
if (rw == NULL) {
printf("PANIC: no waiter\n");
- pthread_mutex_unlock(&spc->spc_mtx);
+ abort();
return;
}
rw->rw_data = spc->spc_buf;
- TAILQ_REMOVE(&spc->spc_respwait, rw, rw_entries);
pthread_cond_signal(&rw->rw_cv);
pthread_mutex_unlock(&spc->spc_mtx);
@@ -288,7 +289,6 @@
if (spc->spc_istatus == SPCSTATUS_WANTED)
kickall(spc);
spc->spc_istatus = SPCSTATUS_FREE;
- pthread_mutex_unlock(&spc->spc_mtx);
} else {
spc->spc_istatus = SPCSTATUS_WANTED;
pthread_cond_wait(&rw->rw_cv, &spc->spc_mtx);
Home |
Main Index |
Thread Index |
Old Index