On 5/13/06, Bob Friesenhahn <[EMAIL PROTECTED]> wrote:
On Fri, 12 May 2006, John Cupitt wrote:
> I've just noticed cmsDoTransform() isn't threadsafe (when I found
> random image corruption on my SMP box, heh).
What part of the code is not thread safe? Are you sure that the
thread safety problem is not a problem with your own application or
the way the lcms library was built?
I'm calling cmsDoTransform() from more than one thread with the same
cmsHTRANSFORM pointer. I see random corruption, like noise, in the
output image. So I guess cmsDoTransform() must be using part of the
transform as working area.
I either have to mutex around each call to cmsDoTransform() (so I lose
parallelism), or I have to have a separate transform for each thread.
The problem with a separate transform for each thread is that
transforms are rather 'heavy' objects. They can take a lot of time to
build, and use a lot of memory (is this correct? I've not done any
tests, but the docs seem to imply this). It seems very wasteful to
have to build many identical transforms.
It seems to me that cmsDoTransform() should not modify the transform
object. Transforms ought to be split into a read-only section (shared
by all threads using that transform), and per-thread storage.
You might be able to change this in a backwards compatible way.
Perhaps cmsDoTransform() could become:
cmsDoTransform( transform, in, out, n )
{
data = cmsTransformDataNew()
cmsDoTransformData( transform, data, in, out, n )
cmsTransformDataFree( data )
}
ie. alloc and free some per-thread storage on each call. But I've no
idea how large the per-thread area needs to be. If this is too slow,
the lcms API would probably have to change.
John
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user