On Sun, Apr 23, 2023 at 12:23 PM Victor Giordano <vitucho3...@gmail.com> wrote:
> Hi there! > > Hope you are having a great weekend (This is actually friendly greeting > and you may greet me as well, it will be more than welcome) > > I reach this line > <https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/sync/atomic/doc.go;l=118> > and > that is folks! > > I was expetecting to find something like > > mutex.Lock() > (*intParam)++ > mutex.Unlock() > > Can anyone give a little insight of this. If the burden of what is > happening implies to assambly code I will be satisfied with any shallow > explanation. If the first time I saw code in golang that reseembles the > code in Java prefixed with native keyword. The implementation is written in assembler, in the file asm.s. In the current implementation it just jumps to the implementation in the runtime/internal/atomic package. In that package, for most targets, look at the atomic_GOARCH.s file. It's not normally implemented using a mutex, it's normally implemented using processor-specific atomic instructions. And I'll add that actually the implementation in runtime/internal/atomic isn't normally used, normally the function is implemented directly by the compiler. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWhiEDuygWwn8wab-jki9pG5R3a4zu67OzWFGiAum8eyw%40mail.gmail.com.