Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/irix Introduce a shared group structure, and make...
details: https://anonhg.NetBSD.org/src/rev/cdf868862447
branches: trunk
changeset: 534781:cdf868862447
user: manu <manu%NetBSD.org@localhost>
date: Fri Aug 02 23:02:51 2002 +0000
description:
Introduce a shared group structure, and make the sproc implementation
more SMP friendly.
diffstat:
sys/compat/irix/irix_exec.c | 50 +++++-
sys/compat/irix/irix_exec.h | 25 ++-
sys/compat/irix/irix_mman.c | 10 +-
sys/compat/irix/irix_prctl.c | 304 +++++++++++++++++++-----------------
sys/compat/irix/irix_syscall.h | 4 +-
sys/compat/irix/irix_syscallargs.h | 4 +-
sys/compat/irix/irix_syscalls.c | 6 +-
sys/compat/irix/irix_sysent.c | 6 +-
8 files changed, 237 insertions(+), 172 deletions(-)
diffs (truncated from 754 to 300 lines):
diff -r 45cad66b2f5a -r cdf868862447 sys/compat/irix/irix_exec.c
--- a/sys/compat/irix/irix_exec.c Fri Aug 02 22:52:50 2002 +0000
+++ b/sys/compat/irix/irix_exec.c Fri Aug 02 23:02:51 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_exec.c,v 1.18 2002/06/12 20:33:20 manu Exp $ */
+/* $NetBSD: irix_exec.c,v 1.19 2002/08/02 23:02:51 manu Exp $ */
/*-
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.18 2002/06/12 20:33:20 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.19 2002/08/02 23:02:51 manu Exp $");
#ifndef ELFSIZE
#define ELFSIZE 32 /* XXX should die */
@@ -46,6 +46,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
+#include <sys/lock.h>
#include <sys/exec.h>
#include <sys/exec_elf.h>
#include <sys/malloc.h>
@@ -254,9 +255,14 @@
struct proc *p;
struct vmspace *vmspace;
{
+ struct irix_emuldata *ied;
+
if (!p->p_emuldata)
- MALLOC(p->p_emuldata, void *, sizeof(struct irix_emuldata),
- M_EMULDATA, M_WAITOK | M_ZERO);
+ p->p_emuldata = malloc(sizeof(struct irix_emuldata),
+ M_EMULDATA, M_WAITOK | M_ZERO);
+
+ ied = p->p_emuldata;
+ ied->ied_p = p;
}
/*
@@ -275,7 +281,7 @@
error = irix_prda_init(p);
#ifdef DEBUG_IRIX
if (error != 0)
- printf("irix_e_proc_init(): PRDA map failed ");
+ printf("irix_e_proc_exec(): PRDA map failed ");
#endif
}
@@ -288,18 +294,48 @@
{
struct proc *pp;
struct irix_emuldata *ied;
+ struct irix_share_group *isg;
+ /*
+ * Send SIGHUP to child process as requested using prctl(2)
+ */
+ proclist_lock_read();
LIST_FOREACH(pp, &allproc, p_list) {
/* Select IRIX processes */
if (irix_check_exec(pp) == 0)
continue;
ied = (struct irix_emuldata *)(pp->p_emuldata);
- if (ied->ied_pptr == p)
+ if (ied->ied_termchild && pp->p_pptr == p)
psignal(pp, native_to_svr4_signo[SIGHUP]);
}
+ proclist_unlock_read();
- FREE(p->p_emuldata, M_EMULDATA);
+ /*
+ * Remove the process from share group processes list, if revelant.
+ */
+ ied = (struct irix_emuldata *)(p->p_emuldata);
+
+ if ((isg = ied->ied_share_group) != NULL) {
+ lockmgr(&isg->isg_lock, LK_EXCLUSIVE, NULL);
+ LIST_REMOVE(ied, ied_sglist);
+ isg->isg_refcount--;
+
+ /*
+ * If the list is now empty, free the share group structure
+ * We don't need to release the lock: there is nobody left
+ * in the share group.
+ */
+ if (isg->isg_refcount == 0) {
+ free(isg, M_EMULDATA);
+ ied->ied_share_group = NULL;
+ } else {
+ lockmgr(&isg->isg_lock, LK_RELEASE, NULL);
+ }
+
+ }
+
+ free(p->p_emuldata, M_EMULDATA);
p->p_emuldata = NULL;
}
diff -r 45cad66b2f5a -r cdf868862447 sys/compat/irix/irix_exec.h
--- a/sys/compat/irix/irix_exec.h Fri Aug 02 22:52:50 2002 +0000
+++ b/sys/compat/irix/irix_exec.h Fri Aug 02 23:02:51 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_exec.h,v 1.11 2002/06/12 20:33:20 manu Exp $ */
+/* $NetBSD: irix_exec.h,v 1.12 2002/08/02 23:02:51 manu Exp $ */
/*-
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -42,6 +42,8 @@
#include <sys/types.h>
#include <sys/exec.h>
#include <sys/signal.h>
+#include <sys/queue.h>
+#include <sys/lock.h>
#include <sys/exec_elf.h>
#include <machine/vmparam.h>
@@ -49,16 +51,27 @@
#include <compat/svr4/svr4_types.h>
#include <compat/svr4/svr4_signal.h>
+/* IRIX share group structure */
+struct irix_share_group {
+ LIST_HEAD(isg_head, irix_emuldata) isg_head; /* list head */
+ struct lock isg_lock; /* list lock */
+ int isg_refcount;
+};
+
/* IRIX specific per-process data, zero'ed on allocation */
struct irix_emuldata {
#define ied_startcopy ied_sigtramp
void *ied_sigtramp[SVR4_NSIG]; /* Address of signal trampoline */
-#define ied_endcopy ied_pptr
- struct proc *ied_pptr; /* parent process or NULL, for SIGHUP on exit */
+#define ied_endcopy ied_termchild
+
+ int ied_termchild; /* want SIGHUP on parent's exit */
int ied_procblk_count; /* semaphore for blockproc */
- struct proc *ied_shareparent; /* parent of the share group */
- int ied_shareaddr; /* VM space is shared with parent */
- /* Only the share group parent keeps track of this: */
+ /* share group proc list head and lock */
+ struct irix_share_group *ied_share_group;
+ /* share group proc list itself */
+ LIST_ENTRY(irix_emuldata) ied_sglist;
+ struct proc *ied_p; /* points back to struct proc */
+ int ied_shareaddr; /* share VM with the group */
};
/* e_flags used by IRIX for ABI selection */
diff -r 45cad66b2f5a -r cdf868862447 sys/compat/irix/irix_mman.c
--- a/sys/compat/irix/irix_mman.c Fri Aug 02 22:52:50 2002 +0000
+++ b/sys/compat/irix/irix_mman.c Fri Aug 02 23:02:51 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_mman.c,v 1.2 2002/06/12 20:33:20 manu Exp $ */
+/* $NetBSD: irix_mman.c,v 1.3 2002/08/02 23:02:51 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_mman.c,v 1.2 2002/06/12 20:33:20 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_mman.c,v 1.3 2002/08/02 23:02:51 manu Exp $");
#include "opt_sysv.h"
@@ -125,6 +125,12 @@
int bsd_flags = 0;
int error = 0;
+#ifdef DEBUG_IRIX
+ printf("irix_sys_mmap(): addr = %p, len = 0x%x, prot = 0x%x ",
+ addr, len, prot);
+ printf("flags = 0x%x, fd = %d, pos = 0x%lx\n", flags, fd, (long)pos);
+
+#endif
if (flags & IRIX_MAP_SHARED)
bsd_flags |= MAP_SHARED;
if (flags & IRIX_MAP_PRIVATE)
diff -r 45cad66b2f5a -r cdf868862447 sys/compat/irix/irix_prctl.c
--- a/sys/compat/irix/irix_prctl.c Fri Aug 02 22:52:50 2002 +0000
+++ b/sys/compat/irix/irix_prctl.c Fri Aug 02 23:02:51 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_prctl.c,v 1.13 2002/06/12 20:33:20 manu Exp $ */
+/* $NetBSD: irix_prctl.c,v 1.14 2002/08/02 23:02:51 manu Exp $ */
/*-
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.13 2002/06/12 20:33:20 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.14 2002/08/02 23:02:51 manu Exp $");
#include <sys/errno.h>
#include <sys/types.h>
@@ -46,7 +46,9 @@
#include <sys/signalvar.h>
#include <sys/systm.h>
#include <sys/exec.h>
+#include <sys/malloc.h>
#include <sys/pool.h>
+#include <sys/lock.h>
#include <sys/filedesc.h>
#include <sys/vnode.h>
#include <sys/resourcevar.h>
@@ -72,6 +74,7 @@
size_t isc_len;
int isc_inh;
struct proc *isc_parent;
+ struct irix_share_group *isc_share_group;
};
static void irix_sproc_child __P((struct irix_sproc_child_args *));
static int irix_sproc __P((void *, unsigned int, void *, caddr_t, size_t,
@@ -128,36 +131,32 @@
case IRIX_PR_GETNSHARE: { /* Number of sproc share group memb.*/
struct irix_emuldata *ied;
- struct proc *pp;
- struct proc *shareparent;
+ struct irix_emuldata *iedp;
+ struct irix_share_group *isg;
int count;
ied = (struct irix_emuldata *)p->p_emuldata;
- shareparent = ied->ied_shareparent;
- if (shareparent == NULL) {
+ if ((isg = ied->ied_share_group) == NULL) {
*retval = 0;
return 0;
}
count = 0;
- LIST_FOREACH(pp, &allproc, p_list) {
- if (irix_check_exec(pp)) {
- ied = (struct irix_emuldata *)pp->p_emuldata;
- if (ied->ied_shareparent == shareparent)
- count++;
- }
- }
+ (void)lockmgr(&isg->isg_lock, LK_SHARED, NULL);
+ LIST_FOREACH(iedp, &isg->isg_head, ied_sglist)
+ count++;
+ (void)lockmgr(&isg->isg_lock, LK_RELEASE, NULL);
*retval = count;
return 0;
break;
}
- case IRIX_PR_TERMCHILD: { /* Send SIGHUP to children on exit */
+ case IRIX_PR_TERMCHILD: { /* Get SIGHUP when parent's exit */
struct irix_emuldata *ied;
ied = (struct irix_emuldata *)(p->p_emuldata);
- ied->ied_pptr = p->p_pptr;
+ ied->ied_termchild = 1;
break;
}
@@ -272,10 +271,10 @@
struct exec_vmcmd vmc;
int error;
struct proc *p2;
- struct proc *pp;
- struct irix_sproc_child_args isc;
+ struct irix_sproc_child_args *isc;
struct irix_emuldata *ied;
struct irix_emuldata *iedp;
+ struct irix_share_group *isg;
segsz_t stacksize;
#ifdef DEBUG_IRIX
@@ -298,6 +297,25 @@
if (inh & IRIX_PR_SDIR)
printf("Warning: unimplemented IRIX sproc flag PR_SDIR\n");
+ /*
+ * If revelant, initialize the share group structure
+ */
+ ied = (struct irix_emuldata *)(p->p_emuldata);
+ if (ied->ied_share_group == NULL) {
+ isg = malloc(sizeof(struct irix_share_group),
+ M_EMULDATA, M_WAITOK);
+ lockinit(&isg->isg_lock, PZERO|PCATCH, "sharegroup", 0, 0);
+ isg->isg_refcount = 0;
+
+ (void)lockmgr(&isg->isg_lock, LK_EXCLUSIVE, NULL);
+ LIST_INIT(&isg->isg_head);
+ LIST_INSERT_HEAD(&isg->isg_head, ied, ied_sglist);
+ isg->isg_refcount++;
+ (void)lockmgr(&isg->isg_lock, LK_RELEASE, NULL);
+
Home |
Main Index |
Thread Index |
Old Index