In C is “i+=1;” atomic?

后端 未结 12 2100
天命终不由人
天命终不由人 2020-12-28 12:58

In C, is i+=1; atomic?

12条回答
  •  萌比男神i
    2020-12-28 13:28

    Although i may not be atomic for the C language, it should be noted that is atomic on most platforms. The GNU C Library documentation states:

    In practice, you can assume that int and other integer types no longer than int are atomic. You can also assume that pointer types are atomic; that is very convenient. Both of these assumptions are true on all of the machines that the GNU C library supports and on all POSIX systems we know of.

提交回复
热议问题