------- Additional Comments From qrczak at knm dot org dot pl  2005-02-24 22:37 
-------
> By your definition of MT-safe, almost no function is MT-safe. Is 'strchr'
> MT-safe if you call it on a string while another function might modify that
> string? No, so lets put automatic locks around 'strchr' and any function that
> might modify a string.

The difference is that almost all uses of strchr are done on data which is not
shared between threads, while many static local initializers are used on objects
which are accessed from multiple threads (when multiple threads are used at 
all).

By your reasoning malloc should be unsafe to use from multiple threads if the
user did not explicitly put a lock around it, because it modifies shared data
(the heap). And errno should not be automatically made thread-local, because it
hurts performance in case thread-locality is not needed. After all, "POSIX puts
the responsibility fully on the application programmer to place locks where
there might be concurrent access. In exchange for this effort, the programmer
gets the performance benefit of there not being locks when they are not needed".
Right?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20099

Reply via email to