Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpkern Add lwp_find() - verbatim copy fro...
details: https://anonhg.NetBSD.org/src/rev/9dcea2a70ea7
branches: trunk
changeset: 344849:9dcea2a70ea7
user: martin <martin%NetBSD.org@localhost>
date: Sun Apr 24 07:45:10 2016 +0000
description:
Add lwp_find() - verbatim copy from the hard kernel.
diffstat:
sys/rump/librump/rumpkern/lwproc.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diffs (52 lines):
diff -r 98b6cd614ea5 -r 9dcea2a70ea7 sys/rump/librump/rumpkern/lwproc.c
--- a/sys/rump/librump/rumpkern/lwproc.c Sun Apr 24 04:26:12 2016 +0000
+++ b/sys/rump/librump/rumpkern/lwproc.c Sun Apr 24 07:45:10 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lwproc.c,v 1.39 2016/04/04 20:47:57 christos Exp $ */
+/* $NetBSD: lwproc.c,v 1.40 2016/04/24 07:45:10 martin Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#define RUMP__CURLWP_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.39 2016/04/04 20:47:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.40 2016/04/24 07:45:10 martin Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -69,6 +69,33 @@
(*l->l_syncobj->sobj_unsleep)(l, cleanup);
}
+/*
+ * Look up a live LWP within the specified process.
+ *
+ * Must be called with p->p_lock held.
+ */
+struct lwp *
+lwp_find(struct proc *p, lwpid_t id)
+{
+ struct lwp *l;
+
+ KASSERT(mutex_owned(p->p_lock));
+
+ LIST_FOREACH(l, &p->p_lwps, l_sibling) {
+ if (l->l_lid == id)
+ break;
+ }
+
+ /*
+ * No need to lock - all of these conditions will
+ * be visible with the process level mutex held.
+ */
+ if (l != NULL && (l->l_stat == LSIDL || l->l_stat == LSZOMB))
+ l = NULL;
+
+ return l;
+}
+
void
lwp_update_creds(struct lwp *l)
{
Home |
Main Index |
Thread Index |
Old Index