Thread-safe assignments
Hi,
I realize that my recent question about atomic setf was pretty
ambiguous. So here is a question narrowed down to something simpler,
which is hopefully more straightforward to answer.
Assume there is a global variable *var*, for example defined like this:
(cl:defvar *var* 42)
Assume there is exactly one thread forever executing the following loop:
(cl:loop
(cl:setf *var* 42)
(cl:setf *var* 84))
Furthermore, assume that other threads either don't touch *var* at
all, or only read from it.
Is it safe to assume that the reading threads will only ever read the
values 42 or 84 from *var*, or should one take into account that every
now and then, *var* may contain garbage (i.e., a bit pattern that
consists partly of the bits of 42, and partly of the bits of 84)?
To generalize, are there datatypes for which it is not safe to assume
that variable assignments are thread-safe in that sense?
What about plain references?
Thanks for any comments,
Pascal
--
Pascal Costanza, mailto:pc@p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium