]> Cypherpunks repositories - gostls13.git/commit
runtime: simplify OpenBSD semaphores
authorMatthew Dempsky <mdempsky@google.com>
Mon, 23 Feb 2015 08:05:30 +0000 (17:05 +0900)
committerJoel Sing <jsing@google.com>
Wed, 25 Feb 2015 02:30:11 +0000 (02:30 +0000)
commit9f926e81c262f11e2980a25f06ac17f3bbeb378a
tree38d5e7d1bd766e356d013f07702ec2b5aeaf87f9
parent1fda57ba725044e61148258ea9e98080b0a35260
runtime: simplify OpenBSD semaphores

OpenBSD's thrsleep system call includes an "abort" parameter, which
specifies a memory address to be tested after being registered on the
sleep channel (i.e., capable of being woken up by thrwakeup).  By
passing a pointer to waitsemacount for this parameter, we avoid race
conditions without needing a lock.  Instead we just need to use
atomicload, cas, and xadd to mutate the semaphore count.

Change-Id: If9f2ab7cfd682da217f9912783cadea7e72283a8
Reviewed-on: https://go-review.googlesource.com/5563
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Joel Sing <jsing@google.com>
src/runtime/os1_openbsd.go
src/runtime/os_openbsd.go