Multithreading with GM
Chris Healer <[email protected]> Tue, 11 Oct 2011 11:52:06 +0000 (UTC)
| Newsgroups | gmane.comp.video.graphicsmagick.bugs |
|---|---|
| Message-ID | <[email protected]> |
I was finally able to get pthreads to work with GM by recompiling it with OpenMP turned off. I'm on OSX, and gcc 4.2, 4.4 and 4.5 would link GM but I'm using Qt with many threads, and any Magick call outside the main thread would crash. This seems to be well documented-ish online (In terms of OpenMP+pThreads), and I'm not entirely sure I need OpenMP for my application. I'm creating an image server and I can spawn new threads on new tcp connections just fine, and serve images from separate threads... Each row of the image is sent as a separate request, and in my initial implementation each thread (which represents a distinct tcp connection) is dispatching those rows in a single thread. As an upgrade I'm trying to process each row (which wants to be transformed into other colorspaces and compressed) in a separate thread before transmitting to the client. So, I have spawned a thread for the tcp connection, which in turn spawns many threads to process each scanline. The problem I'm having is that no combination of Mutexes seems to protect the image cache from flushing unpredictably. As an example, there may be 8 or more threads trying to call something like: Pixels view(img); const PixelPacket *pixels = view.getConst(0,row,img.columns(),1); concurrently. It works fine for a while but eventually it crashes. Running with MAGIC_DEBUG=all reveals: destroy cache [path] Destroy blob, image=0x10282b200, filename="[path]" are reliably the culprits, and: Assertion failed: (image->signature == MagickSignature), function OpenCacheView, file magick/pixel_cache.c, line 3193. is usually thrown (but not always) This makes sense... anyone know of a way to control the flushing, or create a mutex of some kind so I can grant permission for the cache to do its thing? I can't seem to find anything in the documentation like this... ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct