aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/rwmutex_test.go
AgeCommit message (Collapse)Author
2018-04-30all: skip unsupported tests for js/wasmRichard Musiol
The general policy for the current state of js/wasm is that it only has to support tests that are also supported by nacl. The test nilptr3.go makes assumptions about which nil checks can be removed. Since WebAssembly does not signal on reading a null pointer, all nil checks have to be explicit. Updates #18892 Change-Id: I06a687860b8d22ae26b1c391499c0f5183e4c485 Reviewed-on: https://go-review.googlesource.com/110096 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-26runtime: "fix" non-preemptible loop in TestParallelRWMutexReadersAustin Clements
TestParallelRWMutexReaders has a non-preemptible loop in it that can deadlock if GC triggers. "Fix" it like we've fixed similar tests. Updates #10958. Change-Id: I13618f522f5ef0c864e7171ad2f655edececacd7 Reviewed-on: https://go-review.googlesource.com/73710 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-06runtime: prevent descheduling while holding rwmutex read lockAustin Clements
Currently only the rwmutex write lock prevents descheduling. The read lock does not. This leads to the following situation: 1. A reader acquires the lock and gets descheduled. 2. GOMAXPROCS writers attempt to acquire the lock (or at least one writer does, followed by readers). This blocks all of the Ps. 3. There is no 3. The descheduled reader never gets to run again because there are no Ps, so it never releases the lock and the system deadlocks. Fix this by preventing descheduling while holding the read lock. This requires also rewriting TestParallelRWMutexReaders to always create enough GOMAXPROCS and to use non-blocking operations for synchronization. Fixes #20903. Change-Id: Ibd460663a7e5a555be5490e13b2eaaa295fac39f Reviewed-on: https://go-review.googlesource.com/47632 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-28runtime: make rwmutex work on Ms instead of GsAustin Clements
Currently runtime.rwmutex is written to block the calling goroutine rather than the calling thread. However, rwmutex was intended to be used in the scheduler, which means it needs to be a thread-level synchronization primitive. Hence, this modifies rwmutex to synchronize threads instead of goroutines. This has the consequence of making it write-barrier-free, which is also important for using it in the scheduler. The implementation makes three changes: it replaces the "w" semaphore with a mutex, since this was all it was being used for anyway; it replaces "writerSem" with a single pending M that parks on its note; and it replaces "readerSem" with a list of Ms that park on their notes plus a pass count that together emulate a counting semaphore. I model-checked the safety and liveness of this implementation through >1 billion schedules. For #20738. Change-Id: I3cf5a18c266a96a3f38165083812803510217787 Reviewed-on: https://go-review.googlesource.com/47071 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-19runtime: add read/write mutex typeIan Lance Taylor
This is a runtime version of sync.RWMutex that can be used by code in the runtime package. The type is not quite the same, in that the zero value is not valid. For future use by CL 43713. Updates #19546 Change-Id: I431eb3688add16ce1274dab97285f555b72735bf Reviewed-on: https://go-review.googlesource.com/45991 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Austin Clements <austin@google.com>