
We are moving our software towards multithreading (SunOS 5.5.1). One of the many concerns is the MT-unsafety of tzset() function. It is said to be MT-unsafe in man pages. It is partly due to the keeping references to TZ in the environment variable, I guess. Our software needs to deal with more than one timezone in one process. The only way I know to implement it is to change the value of environment variable TZ and call tzset() every time I want to switch to a new timezone. External variables tzname and others also makes it problematic to maintain access to them: other vendors' software we are using might use their own policy of access. How is it possible to manage current zone information in MT-safe fashion? I would appreciate any help. Valery

Date: Mon, 21 Oct 1996 13:03:55 +1000 (EST) From: Valery Aronov <valery@ind.tansu.com.au> How is it possible to manage current zone information in MT-safe fashion? Write and use a thread-safe version of the tz library. This requires changing the interfaces to localtime, gmtime, tzset, etc. (localtime_r is not enough.) One must also make the locale a parameter, for strftime at least. And I'm afraid that this will require going into the guts of the C library, which will make it hard to do portably. On my (long) list of things to do is to make a thread-safe version of the glibc version of the tz library. Once you know you're dealing with that particular library, the job becomes tractable.

<<On Sun, 20 Oct 1996 21:37:51 -0700, Paul Eggert <eggert@twinsun.com> said:
On my (long) list of things to do is to make a thread-safe version of the glibc version of the tz library. Once you know you're dealing with that particular library, the job becomes tractable.
FreeBSD includes a reentry-preventing version of the timezone code. Granted, this is not an ideal state of affairs, but it does allow people to call localtime() in their threaded C programs. (The library simply puts a global lock wrapper around all the time functions that examine the zone structure.) -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, ANA, or NSA| - Susan Aglukark and Chad Irschick

Paul, Garrett - thank for your collaboration! On Mon, 21 Oct 1996, Garrett Wollman wrote:
<<On Sun, 20 Oct 1996 21:37:51 -0700, Paul Eggert <eggert@twinsun.com> said:
On my (long) list of things to do is to make a thread-safe version of the glibc version of the tz library. Once you know you're dealing with that particular library, the job becomes tractable.
FreeBSD includes a reentry-preventing version of the timezone code. Granted, this is not an ideal state of affairs, but it does allow people to call localtime() in their threaded C programs. (The library simply puts a global lock wrapper around all the time functions that examine the zone structure.)
There is a reentrant implemetation in Solaris (except tzset() and tzwall()), but it is not enough for a complete solution, as you perhaps understand. I have requested Sun's opinion before tinkering with the code. Thanks again, Valery
participants (3)
-
Garrett Wollman
-
Paul Eggert
-
Valery Aronov