From owner-freebsd-questions Wed Jan 13 17:32:54 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA05828 for freebsd-questions-outgoing; Wed, 13 Jan 1999 17:32:54 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from guru.phone.net (guru.phone.net [209.157.82.120]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id RAA05816 for ; Wed, 13 Jan 1999 17:32:52 -0800 (PST) (envelope-from mwm@phone.net) Received: (qmail 4760 invoked by uid 100); 14 Jan 1999 01:31:45 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 14 Jan 1999 01:31:45 -0000 Date: Wed, 13 Jan 1999 17:31:45 -0800 (PST) From: Mike Meyer To: "'freebsd-questions@FreeBSD.ORG'" Subject: Re: reentrant code In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Personally, I always thought I had a good grip on what re-entrant meant and what "thread-safe" means. If I correctly understand those, then thread-safe functions should all be reentrant (pretty much required, isn't it?). In which case: On Wed, 13 Jan 1999, Spike Gronim wrote: > According to _Advanced Programming in the Unix Environment_, a reentrant > function must not call malloc(), free(), a function from the standard I/O > library, or a function which uses a static data structure of which there > is only one available to the process. Malloc, free and the standard i/o library are in libc. From 'man pthread': The current FreeBSD POSIX thread implementation is built in the library libc_r which contains both thread-safe libc functions and the thread functions. This library replaces libc for threaded applications. So, by linking with libc_r instead of libc, you should be able to use those routines in functions and have them remain reentrant. These may well be overkill. If that isn't the case, I'd be interested in knowing the technical details of how a thread-safe routine can be non-reentrant. Thanx,