Is there a more efficient threading lock?

Barry barry at barrys-emacs.org
Tue Feb 28 18:04:39 EST 2023


> Though it's still probably not as useful as you might hope. In C, if I
> can do "int id = counter++;" atomically, it would guarantee me a new
> ID that no other thread could ever have.

C does not have to do that atomically. In fact it is free to use lots of instructions to build the int value. And some compilers indeed do, the linux kernel folks see this in gcc generated code.

I understand you have to use the new atomics features.

Barry




More information about the Python-list mailing list