[Gdal-dev] multiple threads - VSIMemFileSystemHandler and nCacheUsed

Frank Warmerdam warmerdam at pobox.com
Tue Jan 10 16:10:05 EST 2006


On 1/10/06, list67 at netscape.net <list67 at netscape.net> wrote:
> Hi.
>
> I read in the FAQ that GDAL is not completely threadsafe, so this info might be insignficant.
>
> The Intel Thread Checker is reporting "read/write data race" errors when run with a program that has multiple threads which call VSIFileFromMemBuffer(..), GDALOpen, VSIUnlink, etc. (all for reading rasters).
>
> Many of the errors seem to be related to the accessing of the VSIMemFileSystemHandler's oFileList data member.

Mike,

Good point.  If you file a bug on this, I'll look into resolving it.

> There are other errors reported with the accessing of the nCacheUsed data member from gdalrasterblock.cpp.

The nCacheUsed variable is used to decide if blocks should
be released from the cache to reduce memory use below
the allowed maximum.  Because it doesn't really matter if it
is a bit off when it is being read, I haven't protected all uses
of this variable with the cache mutex.

However, I think all updates of this variable are protected.
Let me know if that is not the case.

> I'm using a CVS version of GDAL from December 28, 2005.
>
> Are these particular errors to be expected, or is it probably the case that errors are the result of the program using GDAL incorrectly?

Note that it is known to be unsafe to use gdal multithreaded
when you are *writing* files with GDAL.   It is intended that
multiple threads reading through GDAL should be ok,
with some caveats.

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