AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2006.09.22 14:20 "[Tiff] libjpeg", by Philip Watkinson
2006.09.22 14:31 "Re: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 15:22 "Re: [Tiff] libjpeg", by Joris Van Damme
2006.09.22 16:31 "Re: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 17:49 "RE: [Tiff] libjpeg", by Philip Watkinson
2006.09.22 17:09 "RE: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 17:25 "Re: [Tiff] libjpeg", by Joris Van Damme
2006.09.23 00:51 "Re: [Tiff] libjpeg", by Graeme Gill
2006.09.23 01:45 "Re: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 15:20 "Re: [Tiff] libjpeg", by Joris Van Damme
2006.09.22 16:42 "Re: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 17:31 "Re: [Tiff] libjpeg", by Joris Van Damme
2006.09.22 18:09 "Re: [Tiff] libjpeg", by Toby Thain
2006.09.22 18:16 "Re: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 19:21 "Re: [Tiff] libjpeg", by Joris Van Damme
2006.09.22 18:29 "Re: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 19:18 "Re: [Tiff] libjpeg", by Joris Van Damme
2006.09.22 20:09 "Re: [Tiff] libjpeg", by Bob Friesenhahn
2006.09.22 20:21 "Re: [Tiff] libjpeg", by Joris Van Damme

2006.09.22 16:42 "Re: [Tiff] libjpeg", by Bob Friesenhahn

Is libjpeg thread safe?

I believe it is. Of course, 'thread safe' is a misleading classification, in that it seems to indicate calling threads can do

Libtiff's tif_jpeg.c and tif_ojpeg.c are not thread safe due their use of setjmp()/longjmp(). These C APIs were defined long before programs used threads, and saving context may just plain not work. The assembly code used to save context can be quite arcane. For example, the referenced context (which also preserves all necessary CPU registers, including private ones) may be rendered incorrect due to operation of the thread scheduler. The CPU (or hardware thread context) used to throw the exception (via longjmp()) may not be the same as was used to save the context using setjmp(). As processor hardware continues to move forward toward multi-core/multi-thread the problem will just get worse.

Of course if one assumes that there is never an error, then you are blissfully ok. :-)

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/