From owner-freebsd-arch Mon Jun 11 10:33:42 2001 Delivered-To: freebsd-arch@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id CAB1A37B403 for ; Mon, 11 Jun 2001 10:33:18 -0700 (PDT) (envelope-from des@ofug.org) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id TAA11676; Mon, 11 Jun 2001 19:33:17 +0200 (CEST) (envelope-from des@ofug.org) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: arch@freebsd.org Subject: nextpid -> lastpid From: Dag-Erling Smorgrav Date: 11 Jun 2001 19:33:16 +0200 Message-ID: Lines: 13 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --=-=-= The attached patch renames nextpid to lastpid, since most of the time, that's what it is: the PID of the most recently started process (though there is occasionally a very brief window during which it is the PID of a process that hasn't yet started, but is about to). It also externalizes it so linprocfs can access it without having to resort to kernel_sysctlbyname(). DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=lastpid.diff Index: sys/sys/proc.h =================================================================== RCS file: /home/ncvs/src/sys/sys/proc.h,v retrieving revision 1.164 diff -u -r1.164 proc.h --- sys/sys/proc.h 2001/05/25 16:59:10 1.164 +++ sys/sys/proc.h 2001/06/11 17:26:15 @@ -486,6 +486,8 @@ extern struct vm_zone *proc_zone; +extern int nextpid; + /* * XXX macros for scheduler. Shouldn't be here, but currently needed for * bounding the dubious p_estcpu inheritance in wait1(). Index: sys/kern/kern_fork.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_fork.c,v retrieving revision 1.113 diff -u -r1.113 kern_fork.c --- sys/kern/kern_fork.c 2001/05/25 16:59:06 1.113 +++ sys/kern/kern_fork.c 2001/06/11 17:29:55 @@ -158,12 +158,12 @@ int nprocs = 1; /* process 0 */ -static int nextpid = 0; -SYSCTL_INT(_kern, OID_AUTO, lastpid, CTLFLAG_RD, &nextpid, 0, +int lastpid = 0; +SYSCTL_INT(_kern, OID_AUTO, lastpid, CTLFLAG_RD, &lastpid, 0, "Last used PID"); /* - * Random component to nextpid generation. We mix in a random factor to make + * Random component to lastpid generation. We mix in a random factor to make * it a little harder to predict. We sanity check the modulus value to avoid * doing it in critical paths. Don't let it be too small or we pointlessly * waste randomness entropy, and don't let it be impossibly large. Using a @@ -302,13 +302,13 @@ /* * Find an unused process ID. We remember a range of unused IDs - * ready to use (from nextpid+1 through pidchecked-1). + * ready to use (from lastpid+1 through pidchecked-1). * * If RFHIGHPID is set (used during system boot), do not allocate * low-numbered pids. */ sx_xlock(&allproc_lock); - trypid = nextpid + 1; + trypid = lastpid + 1; if (flags & RFHIGHPID) { if (trypid < 10) { trypid = 10; @@ -365,12 +365,12 @@ } /* - * RFHIGHPID does not mess with the nextpid counter during boot. + * RFHIGHPID does not mess with the lastpid counter during boot. */ if (flags & RFHIGHPID) pidchecked = 0; else - nextpid = trypid; + lastpid = trypid; p2 = newproc; p2->p_stat = SIDL; /* protect against others */ --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message