From owner-freebsd-current Fri Aug 7 14:30:22 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA00323 for freebsd-current-outgoing; Fri, 7 Aug 1998 14:30:22 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from cimlogic.com.au (cimlog.lnk.telstra.net [139.130.51.31]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id OAA00251 for ; Fri, 7 Aug 1998 14:30:02 -0700 (PDT) (envelope-from jb@cimlogic.com.au) Received: (from jb@localhost) by cimlogic.com.au (8.8.8/8.8.7) id HAA10923; Sat, 8 Aug 1998 07:35:32 +1000 (EST) (envelope-from jb) From: John Birrell Message-Id: <199808072135.HAA10923@cimlogic.com.au> Subject: Re: memory leaks in libc In-Reply-To: <199808071703.KAA29656@bubba.whistle.com> from Archie Cobbs at "Aug 7, 98 10:03:20 am" To: archie@whistle.com (Archie Cobbs) Date: Sat, 8 Aug 1998 07:35:32 +1000 (EST) Cc: jb@cimlogic.com.au, archie@whistle.com, freebsd-current@FreeBSD.ORG, bde@zeta.org.au, wollman@khavrinen.lcs.mit.edu, dg@root.com X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Archie Cobbs wrote: > Well, setenv() and unsetenv() are not thread safe as they > currently exist. How does this look? FWIW, I think that any proposed changes to libc should be _required_ to be thread-safe from now on so that libc has a better chance of working with kernel threads. > +void > +__env_lock(void) > +{ > + THREAD_LOCK(); > +} > + > +/* > + * __env_unlock() > + * > + * Release mutex lock on the environment. Should be static. > + */ > +void > +__env_unlock(void) > +{ > + THREAD_UNLOCK(); > +} Why add these functions? Since kernel threads require the standard libc to be thread safe, don't expect that the calls will be optimized out. The idea is to make the non-threaded runtime impact just a test on the __is_threaded variable. Using the THREAD_LOCK() and THREAD_UNLOCK() macros directly will achieve this. -- John Birrell - jb@cimlogic.com.au; jb@freebsd.org http://www.cimlogic.com.au/ CIMlogic Pty Ltd, GPO Box 117A, Melbourne Vic 3001, Australia +61 418 353 137 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message