Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/chs-ubc2]: src/sys Update from trunk.



details:   https://anonhg.NetBSD.org/src/rev/4414c7a1236a
branches:  chs-ubc2
changeset: 471441:4414c7a1236a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Aug 02 22:19:11 1999 +0000

description:
Update from trunk.

diffstat:

 sys/kern/exec_subr.c               |   15 +-
 sys/kern/init_main.c               |    9 +-
 sys/kern/kern_exit.c               |   79 ++-
 sys/kern/kern_fork.c               |   18 +-
 sys/kern/kern_fthread.c            |  140 -----
 sys/kern/kern_kthread.c            |   18 +-
 sys/kern/kern_ktrace.c             |   17 +-
 sys/kern/kern_lock.c               |  653 +++++++++++++++++---------
 sys/kern/kern_malloc.c             |   16 +-
 sys/kern/kern_proc.c               |  142 +++++-
 sys/kern/kern_resource.c           |    6 +-
 sys/kern/kern_sig.c                |   12 +-
 sys/kern/kern_synch.c              |  149 +++++-
 sys/kern/kern_sysctl.c             |    7 +-
 sys/kern/subr_pool.c               |   10 +-
 sys/kern/subr_prf.c                |   13 +-
 sys/kern/tty.c                     |    8 +-
 sys/kern/uipc_domain.c             |    3 +-
 sys/kern/vfs_getcwd.c              |  375 +++++----------
 sys/kern/vfs_lookup.c              |   11 +-
 sys/kern/vfs_subr.c                |   71 ++-
 sys/kern/vfs_syscalls.c            |   43 +-
 sys/kern/vnode_if.sh               |   19 +-
 sys/lib/libsa/tftp.c               |   15 +-
 sys/lkm/vfs/miscfs/nullfs/Makefile |    6 +-
 sys/miscfs/fdesc/fdesc_vfsops.c    |    3 +-
 sys/miscfs/fdesc/fdesc_vnops.c     |   74 ++-
 sys/miscfs/genfs/Makefile          |    4 +-
 sys/miscfs/genfs/genfs.h           |   40 +-
 sys/miscfs/genfs/genfs_vnops.c     |  165 +++---
 sys/miscfs/genfs/layer.h           |  167 +++++++
 sys/miscfs/genfs/layer_extern.h    |  118 ++++
 sys/miscfs/genfs/layer_subr.c      |  387 ++++++++++++++++
 sys/miscfs/genfs/layer_vfsops.c    |  285 +++++++++++
 sys/miscfs/genfs/layer_vnops.c     |  880 +++++++++++++++++++++++++++++++++++++
 sys/miscfs/kernfs/kernfs_vnops.c   |   45 +-
 sys/miscfs/nullfs/null.h           |   93 ++-
 sys/miscfs/nullfs/null_subr.c      |  369 ---------------
 sys/miscfs/nullfs/null_vfsops.c    |  322 ++++---------
 sys/miscfs/nullfs/null_vnops.c     |  577 ++----------------------
 sys/miscfs/portal/portal_vnops.c   |   31 +-
 sys/miscfs/procfs/procfs_cmdline.c |    4 +-
 sys/miscfs/procfs/procfs_ctl.c     |    4 +-
 sys/miscfs/procfs/procfs_subr.c    |    8 +-
 sys/miscfs/procfs/procfs_vnops.c   |   98 +++-
 45 files changed, 3458 insertions(+), 2071 deletions(-)

diffs (truncated from 7658 to 300 lines):

diff -r 70e20e4f20b9 -r 4414c7a1236a sys/kern/exec_subr.c
--- a/sys/kern/exec_subr.c      Mon Aug 02 22:18:54 1999 +0000
+++ b/sys/kern/exec_subr.c      Mon Aug 02 22:19:11 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_subr.c,v 1.16.4.1 1999/06/07 04:25:30 chs Exp $   */
+/*     $NetBSD: exec_subr.c,v 1.16.4.2 1999/08/02 22:19:11 thorpej Exp $       */
 
 /*
  * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
@@ -208,11 +208,16 @@
        struct exec_vmcmd *cmd;
 {
        int error;
+       long diff;
 
        if (cmd->ev_len == 0)
                return(KERN_SUCCESS); /* XXXCDC: should it happen? */
        
-       cmd->ev_addr = trunc_page(cmd->ev_addr); /* required by uvm_map */
+       diff = cmd->ev_addr - trunc_page(cmd->ev_addr);
+       cmd->ev_addr -= diff;                   /* required by uvm_map */
+       cmd->ev_offset -= diff;
+       cmd->ev_len += diff;
+
        error = uvm_map(&p->p_vmspace->vm_map, &cmd->ev_addr, 
                        round_page(cmd->ev_len), NULL, UVM_UNKNOWN_OFFSET, 
                        UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_COPY,
@@ -256,11 +261,15 @@
        struct exec_vmcmd *cmd;
 {
        int error;
+       long diff;
 
        if (cmd->ev_len == 0)
                return(KERN_SUCCESS); /* XXXCDC: should it happen? */
        
-       cmd->ev_addr = trunc_page(cmd->ev_addr); /* required by uvm_map */
+       diff = cmd->ev_addr - trunc_page(cmd->ev_addr);
+       cmd->ev_addr -= diff;                   /* required by uvm_map */
+       cmd->ev_len += diff;
+
        error = uvm_map(&p->p_vmspace->vm_map, &cmd->ev_addr, 
                        round_page(cmd->ev_len), NULL, UVM_UNKNOWN_OFFSET, 
                        UVM_MAPFLAG(cmd->ev_prot, UVM_PROT_ALL, UVM_INH_COPY,
diff -r 70e20e4f20b9 -r 4414c7a1236a sys/kern/init_main.c
--- a/sys/kern/init_main.c      Mon Aug 02 22:18:54 1999 +0000
+++ b/sys/kern/init_main.c      Mon Aug 02 22:19:11 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.145.4.2 1999/06/21 01:23:59 thorpej Exp $      */
+/*     $NetBSD: init_main.c,v 1.145.4.3 1999/08/02 22:19:11 thorpej Exp $      */
 
 /*
  * Copyright (c) 1995 Christopher G. Demetriou.  All rights reserved.
@@ -226,7 +226,10 @@
        /*
         * Create process 0 (the swapper).
         */
+       s = proclist_lock_write();
        LIST_INSERT_HEAD(&allproc, p, p_list);
+       proclist_unlock_write(s);
+
        p->p_pgrp = &pgrp0;
        LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
        LIST_INIT(&pgrp0.pg_members);
@@ -410,11 +413,11 @@
        cpu_set_kpc(initproc, start_init, initproc);
 
        /* Create process 2, the pageout daemon kernel thread. */
-       if (kthread_create(start_pagedaemon, NULL, NULL, "pagedaemon"))
+       if (kthread_create1(start_pagedaemon, NULL, NULL, "pagedaemon"))
                panic("fork pagedaemon");
 
        /* Create process 3, the process reaper kernel thread. */
-       if (kthread_create(start_reaper, NULL, NULL, "reaper"))
+       if (kthread_create1(start_reaper, NULL, NULL, "reaper"))
                panic("fork reaper");
 
        /* Create process 4, the aiodone daemon kernel thread. */
diff -r 70e20e4f20b9 -r 4414c7a1236a sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Mon Aug 02 22:18:54 1999 +0000
+++ b/sys/kern/kern_exit.c      Mon Aug 02 22:19:11 1999 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: kern_exit.c,v 1.65.4.1 1999/06/21 01:24:01 thorpej Exp $       */
+/*     $NetBSD: kern_exit.c,v 1.65.4.2 1999/08/02 22:19:12 thorpej Exp $       */
 
 /*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -152,10 +152,12 @@
 {
        register struct proc *q, *nq;
        register struct vmspace *vm;
+       int s;
 
-       if (p->p_pid == 1)
+       if (p == initproc)
                panic("init died (signal %d, exit %d)",
                    WTERMSIG(rv), WEXITSTATUS(rv));
+
 #ifdef PGINPROF
        vmsizmon();
 #endif
@@ -246,18 +248,26 @@
        ktrderef(p);
 #endif
        /*
-        * Remove proc from allproc queue and pidhash chain.
-        * Unlink from parent's child list.
+        * NOTE: WE ARE NO LONGER ALLOWED TO SLEEP!
         */
-       LIST_REMOVE(p, p_list);
-       p->p_stat = SZOMB;
+       p->p_stat = SDEAD;
 
        /*
-        * NOTE: WE ARE NO LONGER ALLOWED TO SLEEP!
+        * Remove proc from pidhash chain so looking it up won't
+        * work.  Move it from allproc to zombproc, but do not yet
+        * wake up the reaper.  We will put the proc on the
+        * deadproc list later (using the p_hash member), and
+        * wake up the reaper when we do.
         */
+       s = proclist_lock_write();
+       LIST_REMOVE(p, p_hash);
+       LIST_REMOVE(p, p_list);
+       LIST_INSERT_HEAD(&zombproc, p, p_list);
+       proclist_unlock_write(s);
 
-       LIST_REMOVE(p, p_hash);
-
+       /*
+        * Give orphaned children to init(8).
+        */
        q = p->p_children.lh_first;
        if (q)          /* only need this if any child is S_ZOMB */
                wakeup((caddr_t)initproc);
@@ -335,13 +345,23 @@
 /*
  * We are called from cpu_exit() once it is safe to schedule the
  * dead process's resources to be freed.
+ *
+ * NOTE: One must be careful with locking in this routine.  It's
+ * called from a critical section in machine-dependent code, so
+ * we should refrain from changing any interrupt state.
+ *
+ * We lock the deadproc list (a spin lock), place the proc on that
+ * list (using the p_hash member), and wake up the reaper.
  */
 void
 exit2(p)
        struct proc *p;
 {
 
-       LIST_INSERT_HEAD(&deadproc, p, p_list);
+       simple_lock(&deadproc_slock);
+       LIST_INSERT_HEAD(&deadproc, p, p_hash);
+       simple_unlock(&deadproc_slock);
+
        wakeup(&deadproc);
 }
 
@@ -356,15 +376,26 @@
        struct proc *p;
 
        for (;;) {
+               simple_lock(&deadproc_slock);
                p = LIST_FIRST(&deadproc);
                if (p == NULL) {
                        /* No work for us; go to sleep until someone exits. */
+                       simple_unlock(&deadproc_slock);
                        (void) tsleep(&deadproc, PVM, "reaper", 0);
                        continue;
                }
 
                /* Remove us from the deadproc list. */
-               LIST_REMOVE(p, p_list);
+               LIST_REMOVE(p, p_hash);
+               simple_unlock(&deadproc_slock);
+
+               /*
+                * Give machine-dependent code a chance to free any
+                * resources it couldn't free while still running on
+                * that process's context.  This must be done before
+                * uvm_exit(), in case these resources are in the PCB.
+                */
+               cpu_wait(p);
 
                /*
                 * Free the VM resources we're still holding on to.
@@ -374,10 +405,10 @@
                uvm_exit(p);
 
                /* Process is now a true zombie. */
-               LIST_INSERT_HEAD(&zombproc, p, p_list);
+               p->p_stat = SZOMB;
 
                /* Wake up the parent so it can get exit status. */
-               if ((p->p_flag & P_FSTRACE) == 0)
+               if ((p->p_flag & P_FSTRACE) == 0 && p->p_exitsig != 0)
                        psignal(p->p_pptr, P_EXITSIG(p));
                wakeup((caddr_t)p->p_pptr);
        }
@@ -397,7 +428,7 @@
        } */ *uap = v;
        register int nfound;
        register struct proc *p, *t;
-       int status, error;
+       int status, error, s;
 
        if (SCARG(uap, pid) == 0)
                SCARG(uap, pid) = -q->p_pgid;
@@ -416,8 +447,8 @@
                 * if WALTSIG is set; wait for processes with p_exitsig ==
                 * SIGCHLD only if WALTSIG is clear.
                 */
-               if ((SCARG(uap, options) & WALTSIG) ? P_EXITSIG(p) == SIGCHLD :
-                                                     P_EXITSIG(p) != SIGCHLD)
+               if ((SCARG(uap, options) & WALTSIG) ?
+                   (p->p_exitsig == SIGCHLD) : (P_EXITSIG(p) != SIGCHLD))
                        continue;
 
                nfound++;
@@ -451,7 +482,8 @@
                                proc_reparent(p, t ? t : initproc);
                                p->p_oppid = 0;
                                p->p_flag &= ~(P_TRACED|P_WAITED|P_FSTRACE);
-                               psignal(p->p_pptr, P_EXITSIG(p));
+                               if (p->p_exitsig != 0)
+                                       psignal(p->p_pptr, P_EXITSIG(p));
                                wakeup((caddr_t)p->p_pptr);
                                return (0);
                        }
@@ -466,7 +498,9 @@
                         */
                        leavepgrp(p);
 
+                       s = proclist_lock_write();
                        LIST_REMOVE(p, p_list); /* off zombproc */
+                       proclist_unlock_write(s);
 
                        LIST_REMOVE(p, p_sibling);
 
@@ -489,12 +523,6 @@
                        if (p->p_textvp)
                                vrele(p->p_textvp);
 
-                       /*
-                        * Give machine-dependent layer a chance
-                        * to free anything that cpu_exit couldn't
-                        * release while still running in process context.
-                        */
-                       cpu_wait(p);
                        pool_put(&proc_pool, p);
                        nprocs--;
                        return (0);
@@ -537,6 +565,9 @@
        if (child->p_pptr == parent)
                return;
 
+       if (parent == initproc)
+               child->p_exitsig = SIGCHLD;
+
        LIST_REMOVE(child, p_sibling);
        LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
        child->p_pptr = parent;
diff -r 70e20e4f20b9 -r 4414c7a1236a sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c      Mon Aug 02 22:18:54 1999 +0000
+++ b/sys/kern/kern_fork.c      Mon Aug 02 22:19:11 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_fork.c,v 1.54.4.1 1999/06/21 01:24:01 thorpej Exp $       */
+/*     $NetBSD: kern_fork.c,v 1.54.4.2 1999/08/02 22:19:12 thorpej Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -172,8 +172,9 @@
        newproc = pool_get(&proc_pool, PR_WAITOK);
 
        /*
-        * BEGIN PID ALLOCATION.  (Lock PID allocation variables eventually).
+        * BEGIN PID ALLOCATION.
         */
+       s = proclist_lock_write();
 
        /*
         * Find an unused process ID.  We remember a range of unused IDs
@@ -244,17 +245,20 @@
         * Put the proc on allproc before unlocking PID allocation
         * so that waiters won't grab it as soon as we unlock.
         */
-       LIST_INSERT_HEAD(&allproc, p2, p_list);
-
-       /*
-        * END PID ALLOCATION.  (Unlock PID allocation variables).
-        */
 
        p2->p_stat = SIDL;                      /* protect against others */
        p2->p_forw = p2->p_back = NULL;         /* shouldn't be necessary */



Home | Main Index | Thread Index | Old Index