[gdal-dev] GDAL ReadRaster thread-safe?

Frank Warmerdam warmerdam at pobox.com
Thu Jan 8 12:09:02 EST 2009


Eric Domazlicky wrote:
> I am developing a tiling application and I was hoping to up the speed a 
> bit by doing some multithreading. What I want to do is start each of 3 
> ReadRaster calls in seperate threads (using BeginInvoke delegates), then 
> wait for them to complete and build my RGB image (using EndInvoke). I am 
> using the C# wrapper to the GDAL library. This multithreaded approach is 
> showing clear signs of race conditions, with some of the channels not 
> appearing, random crashes etc. If I ensure each thread completes before 
> I go on to read the next Raster Band it works fine.
>  
> Is there anyway to make ReadRaster thread-safe? Maybe by disabling 
> caching which I suspect is the problem.

Eric,

GDAL is intended to support multi-threading for the case where each thread
is accessing a distinct dataset object.  It is certainly not safe to have
more than one thread accessing a single dataset object at the same time.
If nothing else, there is generally only one underlying FILE * for accessing
the physical file.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list