[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-09-03 (07:05) |
From: | Bardur Arantsson <spam@s...> |
Subject: | Re: Unix.localtime not threadsafe? |
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'