Are functions in the C standard library thread safe?

后端 未结 3 1615
鱼传尺愫
鱼传尺愫 2020-12-30 03:41

Where can I get a definitive answer, whether my memcpy (using the eglibc implementation that comes with Ubuntu) is thread safe? - Honestly, I really did not fin

3条回答
  •  不知归路
    2020-12-30 04:42

    It depends on the function, and how you use it.

    Take for example memcpy, it is generally thread safe, if you copy data where both source and destination is private to a single thread. If you write to data that can be read from/written to by another thread, it's no longer thread safe and you have to protect the access.

提交回复
热议问题