質問編集履歴

3

修正

2018/07/17 12:22

投稿

puroko3
puroko3

スコア185

test CHANGED
File without changes
test CHANGED
@@ -98,7 +98,9 @@
98
98
 
99
99
 
100
100
 
101
+ fmt.Println(<-semaphore, "semaphore受信")
102
+
101
- エラーメッセージ
103
+ の部分をコメントアウトした時のエラーメッセージ
102
104
 
103
105
  fatal error: all goroutines are asleep - deadlock!
104
106
 

2

エラースタックトレースの追記

2018/07/17 12:22

投稿

puroko3
puroko3

スコア185

test CHANGED
File without changes
test CHANGED
@@ -94,4 +94,102 @@
94
94
 
95
95
 
96
96
 
97
- わかるかたいらしたらお願いします
97
+ わかるかたいらしたらお願いします
98
+
99
+
100
+
101
+ エラーメッセージ
102
+
103
+ fatal error: all goroutines are asleep - deadlock!
104
+
105
+
106
+
107
+ goroutine 1 [chan receive]:
108
+
109
+ main.main()
110
+
111
+ C:/Go/src/mytest/test1.go:33 +0x18b
112
+
113
+ goroutine 5 [chan send]:
114
+
115
+ main.main.func1(0x0, 0xc04206a080, 0xc042076000)
116
+
117
+ C:/Go/src/mytest/test1.go:22 +0x3e
118
+
119
+ created by main.main
120
+
121
+ C:/Go/src/mytest/test1.go:20 +0x14b
122
+
123
+
124
+
125
+ goroutine 6 [chan send]:
126
+
127
+ main.main.func1(0x1, 0xc04206a080, 0xc042076000)
128
+
129
+ C:/Go/src/mytest/test1.go:22 +0x3e
130
+
131
+ created by main.main
132
+
133
+ C:/Go/src/mytest/test1.go:20 +0x14b
134
+
135
+
136
+
137
+ goroutine 7 [chan send]:
138
+
139
+ main.main.func1(0x2, 0xc04206a080, 0xc042076000)
140
+
141
+ C:/Go/src/mytest/test1.go:22 +0x3e
142
+
143
+ created by main.main
144
+
145
+ C:/Go/src/mytest/test1.go:20 +0x14b
146
+
147
+
148
+
149
+ goroutine 10 [chan send]:
150
+
151
+ main.main.func1(0x5, 0xc04206a080, 0xc042076000)
152
+
153
+ C:/Go/src/mytest/test1.go:22 +0x3e
154
+
155
+ created by main.main
156
+
157
+ C:/Go/src/mytest/test1.go:20 +0x14b
158
+
159
+
160
+
161
+ goroutine 11 [chan send]:
162
+
163
+ main.main.func1(0x6, 0xc04206a080, 0xc042076000)
164
+
165
+ C:/Go/src/mytest/test1.go:22 +0x3e
166
+
167
+ created by main.main
168
+
169
+ C:/Go/src/mytest/test1.go:20 +0x14b
170
+
171
+
172
+
173
+ goroutine 12 [chan send]:
174
+
175
+ main.main.func1(0x7, 0xc04206a080, 0xc042076000)
176
+
177
+ C:/Go/src/mytest/test1.go:22 +0x3e
178
+
179
+ created by main.main
180
+
181
+ C:/Go/src/mytest/test1.go:20 +0x14b
182
+
183
+
184
+
185
+ goroutine 13 [chan send]:
186
+
187
+ main.main.func1(0x8, 0xc04206a080, 0xc042076000)
188
+
189
+ C:/Go/src/mytest/test1.go:22 +0x3e
190
+
191
+ created by main.main
192
+
193
+ C:/Go/src/mytest/test1.go:20 +0x14b
194
+
195
+ exit status 2

1

受信する部分が送信になっていたので修正

2018/07/17 11:30

投稿

puroko3
puroko3

スコア185

test CHANGED
File without changes
test CHANGED
@@ -50,7 +50,7 @@
50
50
 
51
51
  //semaphoreに送信された値を取り出してバッファを解放する。解放しなかれば3回ループした時点で止まる。
52
52
 
53
- fmt.Println(<-semaphore, "semaphore信")
53
+ fmt.Println(<-semaphore, "semaphore信")
54
54
 
55
55
  //notifyに引数のnoを送信する
56
56
 
@@ -64,7 +64,7 @@
64
64
 
65
65
  //notifyに送信された値を全て取り出す。同期の意味合いも持つ
66
66
 
67
- fmt.Println(<-notify, "notify信")
67
+ fmt.Println(<-notify, "notify信")
68
68
 
69
69
  }
70
70
 
@@ -86,7 +86,7 @@
86
86
 
87
87
  このコードを実行させると大体の場合、forのiの0から3以上が表示されて、
88
88
 
89
- その後、semaphoreの信が表示されるのですが、その前にsemaphore <- 0の部分が3つまでしか受け取れないのでエラーが起きてしまうように感じます。
89
+ その後、semaphoreの信が表示されるのですが、その前にsemaphore <- 0の部分が3つまでしか受け取れないのでエラーが起きてしまうように感じます。
90
90
 
91
91
 
92
92