[GRASS-dev] Rast_get_row thread safe

Glynn Clements glynn at gclements.plus.com
Tue Jul 13 11:58:54 EDT 2010


Peng Du wrote:

> Is this call thread safe?
> 
> Rast_get_row(fds[j], rowbuf, row, maptype);
> 
> 
> I've been getting error while trying to put it in an OpenMP loop:

It should be safe to have multiple concurrent Rast_get_row() calls
provided that they refer to different maps. I put some effort into
fixing this issue for the multi-threaded r.mapcalc. Of course, it's
always possible that I overlooked something.

It definitely isn't safe to have multiple concurrent Rast_get_row()
calls for different rows within the same map.

Also, any multi-threaded code should call G_init_all() and
Rast_init_all() before creating additional threads, in order to
prevent race conditions with first-use initialisation.

> Also same question about this two calls:
> 
> ptr = G_incr_void_ptr(ptr, Rast_cell_size(maptype));
> maptype = Rast_get_map_type(fds[j]);

These are both safe.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list