caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Bardur Arantsson <spam@scientician.net>
To: caml-list@inria.fr
Subject: Re: Unix.localtime not threadsafe?
Date: Sat, 03 Sep 2005 09:03:08 +0200	[thread overview]
Message-ID: <dfbhrc$e28$1@sea.gmane.org> (raw)
In-Reply-To: <891bd339050902103460db1a55@mail.gmail.com>

Yaron Minsky wrote:
> I was looking at the Unix.localtime implementation, and it appears to
> me that it's not threadsafe.  I'm wondering if anyone can confirm.
> 
> First off, the underlying localtime call is definitely not re-entrant.
>  The tm data structure is shared among all calls, leading to the
> possibility of races.  What I'm not sure of is whether there can be a
> race given the locking of the OCaml runtime.  Here's the code from
> gmtime.c in the ocaml distribution:

I don't think the glibc/Linux localtime() man page explicitly states 
this, but I expect that it returns a pointer to a *thread-local* 
statically allocated struct tm... in which case there's no problem.

Most other system functions whose API looks non-threadsafe do the same. 
('errno' would be the standard example).

[--snip--]

-- 
Bardur Arantsson
<bardur@imada.sdu.dk>
<bardur@scientician.net>

- But don't be reading my mind between 4 and 5. That's Willie's
time!
                              Groundskeeper Willie, 'The Simpsons'


  reply	other threads:[~2005-09-03  7:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-02 17:34 Yaron Minsky
2005-09-03  7:03 ` Bardur Arantsson [this message]
2005-09-03  7:20   ` [Caml-list] " Florian Weimer
2005-09-03  7:54 ` [Caml-list] " Xavier Leroy
2005-09-03 11:14   ` Yaron Minsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='dfbhrc$e28$1@sea.gmane.org' \
    --to=spam@scientician.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).