Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Message-ID: <012701c0cac0$ebd4d760$0200a8c0@lifelesswks> From: "Robert Collins" To: , References: <987861904 DOT 20126 DOT ezmlm AT sources DOT redhat DOT com> <3AE1C5B2 DOT B63F2B54 AT ece DOT gatech DOT edu> <20010421192518 DOT E4033 AT redhat DOT com> Subject: Re: vfscanf in newlib Date: Sun, 22 Apr 2001 10:12:28 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-OriginalArrivalTime: 22 Apr 2001 00:04:31.0217 (UTC) FILETIME=[CE206E10:01C0CABF] ----- Original Message ----- From: "Christopher Faylor" To: ; ; Sent: Sunday, April 22, 2001 9:25 AM Subject: Re: vfscanf in newlib > On Sat, Apr 21, 2001 at 01:38:58PM -0400, Charles S. Wilson wrote: > >Didn't somebody already do a threadsafeness audit of newlib? If so, > >then we don't want to break threadsafeness with these changes. I'm not > >familiar with threaded code in C; what is neccessary to insure that a > >given function is both reentrant and threadsafe (if a block of code is > >threadsafe it is automatically reentrant, but a reentrant block is not > >necessarily threadsafe, right?) Correct. re-entrant code does not uses passed parameters, read-only data and local-nonstatic variables only. Any exceptions to that list are protected by mutex's/critical sections and the like. Essentially calling the same function while another process or thread is paused within it won't cause problems. Threadsafe adds the requirement that concurrent processing of the code (say on two threads executing on two processors) will not cause problems. This generally involves syncronising all access to non-local variables (in addition to the reentrant requirements). (Syncronisation can be as simple as using InterLockedExchange when adding to a list, or as complex as mutex and condition vars with trylock()s and more.) > That's right. > > AFAIK, newlib is not guaranteed to be thread safe. > > So, I guess that Cygwin is, by extension, not really thread safe either. > > I can think of a few functions in cygwin that are not thread safe, in > fact. The enviroment manipulation is not thread-safe. I don't believe > that vfork is thread safe. I'm sure that there are many others. Well the SUS doesn't require libc to be thread-safe. It only requires the thread-safe functions (not all of which are named _r) to be threadsafe. IMO we should only introduce _r versions of functions when t hey are thread-safe. Rob > > cgf >