diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2014-08-25 11:56:25 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-08-25 11:56:25 +0400 |
| commit | 8ca564fb3fe0b8d6f4d7c660f9df9c1bbcc0539e (patch) | |
| tree | 25c398d7717a0e8806492fcd5664d6c2f8346e08 /src | |
| parent | f6ceefa2bf9a36f60395662aa2122b50eb61f0ac (diff) | |
| download | go-8ca564fb3fe0b8d6f4d7c660f9df9c1bbcc0539e.tar.xz | |
runtime: fix block profile for sync semaphores
And add a test.
LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/128670043
Diffstat (limited to 'src')
| -rw-r--r-- | src/pkg/runtime/pprof/pprof_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/pkg/runtime/pprof/pprof_test.go b/src/pkg/runtime/pprof/pprof_test.go index 9ab211c2da..45db6c59a7 100644 --- a/src/pkg/runtime/pprof/pprof_test.go +++ b/src/pkg/runtime/pprof/pprof_test.go @@ -315,6 +315,12 @@ func TestBlockProfile(t *testing.T) { # 0x[0-9,a-f]+ runtime/pprof_test\.blockMutex\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+ # 0x[0-9,a-f]+ runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+ `}, + {"cond", blockCond, ` +[0-9]+ [0-9]+ @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ +# 0x[0-9,a-f]+ sync\.\(\*Cond\)\.Wait\+0x[0-9,a-f]+ .*/src/pkg/sync/cond\.go:[0-9]+ +# 0x[0-9,a-f]+ runtime/pprof_test\.blockCond\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9,a-f]+ runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+ +`}, } runtime.SetBlockProfileRate(1) @@ -401,3 +407,17 @@ func blockMutex() { }() mu.Lock() } + +func blockCond() { + var mu sync.Mutex + c := sync.NewCond(&mu) + mu.Lock() + go func() { + time.Sleep(blockDelay) + mu.Lock() + c.Signal() + mu.Unlock() + }() + c.Wait() + mu.Unlock() +} |
