1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:24:40 -07:00
The Go programming language
Go to file
Adam Langley 50d6c81d4a runtime: fix race condition
(Thanks to ken and rsc for pointing this out)

rsc:
	ken pointed out that there's a race in the new
	one-lock-per-channel code.  the issue is that
	if one goroutine has gone to sleep doing

	select {
	case <-c1:
	case <-c2:
	}

	and then two more goroutines try to send
	on c1 and c2 simultaneously, the way that
	the code makes sure only one wins is the
	selgen field manipulation in dequeue:

	       // if sgp is stale, ignore it
	       if(sgp->selgen != sgp->g->selgen) {
		       //prints("INVALID PSEUDOG POINTER\n");
		       freesg(c, sgp);
		       goto loop;
	       }

	       // invalidate any others
	       sgp->g->selgen++;

	but because the global lock is gone both
	goroutines will be fiddling with sgp->g->selgen
	at the same time.

This results in a 7% slowdown in the single threaded case for a
ping-pong microbenchmark.

Since the cas predominantly succeeds, adding a simple check first
didn't make any difference.

R=rsc
CC=golang-dev
https://golang.org/cl/180068
2009-12-18 12:25:53 -08:00
doc make it more explicit that design discussions should happen before code reviews 2009-12-17 12:12:47 +11:00
include Ports of lib9, libbio and libmach to Windows. 2009-11-30 11:53:11 -08:00
lib codereview: add golang-dev@googlegroups.com 2009-12-15 13:36:05 -08:00
misc 1) Change default gofmt default settings for 2009-12-15 15:33:31 -08:00
pkg more description 2009-10-15 23:08:46 -07:00
src runtime: fix race condition 2009-12-18 12:25:53 -08:00
test runtime: fix race condition 2009-12-18 12:25:53 -08:00
.hgignore build Make.deps during make.bash instead 2009-11-19 16:27:13 -08:00
.hgtags hgtags: add release tag, again. 2009-12-09 14:55:31 -08:00
AUTHORS A+C: Ben Olive (individual CLA) 2009-12-17 13:38:28 -08:00
CONTRIBUTORS A+C: Ben Olive (individual CLA) 2009-12-17 13:38:28 -08:00
favicon.ico add a favicon plus a couple of hi-res versions of gordon 2009-10-26 10:13:07 -07:00
LICENSE Add AUTHORS and LICENSE files. 2009-08-13 09:21:28 -07:00
README add a README file, so that if someone finds a 2009-11-08 09:57:37 -08:00

This is the source code repository for the Go programming language.  

For documentation about how to install and use Go,
visit http://golang.org/ or load doc/install.html in your web browser.

After installing Go, you can view a nicely formatted
doc/install.html by running godoc --http=:6060
and then visiting http://localhost:6060/doc/install.html.

Unless otherwise noted, the Go source files are distributed
under the BSD-style license found in the LICENSE file.