Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(14532)

Issue 5309070: code review 5309070: runtime: lock the main goroutine to the main OS thread (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 5 months ago by rsc
Modified:
12 years, 5 months ago
Reviewers:
CC:
iant, r, dfc, dvyukov, golang-dev
Visibility:
Public.

Description

runtime: lock the main goroutine to the main OS thread during init We only guarantee that the main goroutine runs on the main OS thread for initialization. Programs that wish to preserve that property for main.main can call runtime.LockOSThread. This is what programs used to do before we unleashed goroutines during init, so it is both a simple fix and keeps existing programs working.

Patch Set 1 #

Patch Set 2 : diff -r 181517df0815 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 181517df0815 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 181517df0815 https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 5 : diff -r 3f70682b9214 https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r 3f70682b9214 https://go.googlecode.com/hg/ #

Patch Set 7 : diff -r 738f105abf75 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+50 lines, -48 lines) Patch
M src/pkg/runtime/386/asm.s View 1 2 chunks +1 line, -10 lines 0 comments Download
M src/pkg/runtime/amd64/asm.s View 1 2 chunks +1 line, -10 lines 0 comments Download
M src/pkg/runtime/arm/asm.s View 1 2 chunks +1 line, -15 lines 0 comments Download
M src/pkg/runtime/debug.go View 1 1 chunk +0 lines, -1 line 0 comments Download
M src/pkg/runtime/proc.c View 1 2 3 4 5 5 chunks +45 lines, -12 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 23
rsc
Hello iant, r (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 5 months ago (2011-10-27 02:41:21 UTC) #1
r
I pre-emptively claim this as too expensive, and surprisingly and unpredictably to boot. Every little ...
12 years, 5 months ago (2011-10-27 03:12:56 UTC) #2
iant2
"Rob 'Commander' Pike" <r@golang.org> writes: > I pre-emptively claim this as too expensive, and surprisingly ...
12 years, 5 months ago (2011-10-27 04:04:27 UTC) #3
rsc
On Wed, Oct 26, 2011 at 20:12, Rob 'Commander' Pike <r@golang.org> wrote: > I pre-emptively ...
12 years, 5 months ago (2011-10-27 04:27:22 UTC) #4
rsc
On Wed, Oct 26, 2011 at 21:04, Ian Lance Taylor <iant@google.com> wrote: > It really ...
12 years, 5 months ago (2011-10-27 04:31:03 UTC) #5
r
But doesn't essentially every program use cgo now, because of networking? -rob
12 years, 5 months ago (2011-10-27 04:36:06 UTC) #6
rsc
On Wed, Oct 26, 2011 at 21:36, Rob 'Commander' Pike <r@golang.org> wrote: > But doesn't ...
12 years, 5 months ago (2011-10-27 04:51:33 UTC) #7
dfc
Hi Russ, How would the 'only if you use CGO' requirement fit with something that ...
12 years, 5 months ago (2011-10-27 05:16:30 UTC) #8
iant2
Russ Cox <rsc@golang.org> writes: > On Wed, Oct 26, 2011 at 21:04, Ian Lance Taylor ...
12 years, 5 months ago (2011-10-27 05:37:47 UTC) #9
rsc
On Wed, Oct 26, 2011 at 22:16, Dave Cheney <dave@cheney.net> wrote: > How would the ...
12 years, 5 months ago (2011-10-27 05:40:57 UTC) #10
rsc
On Wed, Oct 26, 2011 at 22:37, Ian Lance Taylor <iant@google.com> wrote: > Or, on ...
12 years, 5 months ago (2011-10-27 06:02:07 UTC) #11
r2
> How about doing that on all systems: during initialization the main > goroutine is ...
12 years, 5 months ago (2011-10-27 06:33:09 UTC) #12
dvyukov
I have a bad feeling about locking main goroutine to main thread either. However, it's ...
12 years, 5 months ago (2011-10-27 07:46:57 UTC) #13
rsc
On Wed, Oct 26, 2011 at 23:33, Rob 'Commander' Pike <r@google.com> wrote: >> How about ...
12 years, 5 months ago (2011-10-27 07:59:16 UTC) #14
dvyukov
On 2011/10/27 07:59:16, rsc wrote: > On Wed, Oct 26, 2011 at 23:33, Rob 'Commander' ...
12 years, 5 months ago (2011-10-27 08:12:53 UTC) #15
rsc
PTAL I have updated the code to force init (only) onto the main thread. After ...
12 years, 5 months ago (2011-10-27 14:53:51 UTC) #16
r
LGTM at least as an experiment.
12 years, 5 months ago (2011-10-27 15:47:26 UTC) #17
iant
http://codereview.appspot.com/5309070/diff/14001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): http://codereview.appspot.com/5309070/diff/14001/src/pkg/runtime/proc.c#newcode1564 src/pkg/runtime/proc.c:1564: if(m == &runtime·m0 && runtime·sched.init) { The logic here ...
12 years, 5 months ago (2011-10-27 16:19:50 UTC) #18
dvyukov
http://codereview.appspot.com/5309070/diff/14001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): http://codereview.appspot.com/5309070/diff/14001/src/pkg/runtime/proc.c#newcode221 src/pkg/runtime/proc.c:221: Delete empty line. http://codereview.appspot.com/5309070/diff/14001/src/pkg/runtime/proc.c#newcode228 src/pkg/runtime/proc.c:228: runtime·sched.init = true; Where ...
12 years, 5 months ago (2011-10-27 16:21:28 UTC) #19
dvyukov
http://codereview.appspot.com/5309070/diff/14001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): http://codereview.appspot.com/5309070/diff/14001/src/pkg/runtime/proc.c#newcode229 src/pkg/runtime/proc.c:229: runtime·LockOSThread(); Is m already set to m0 here? If ...
12 years, 5 months ago (2011-10-27 16:23:36 UTC) #20
rsc
PTAL I should not write code first thing in the morning. Yay code reviews.
12 years, 5 months ago (2011-10-27 19:30:37 UTC) #21
iant
LGTM
12 years, 5 months ago (2011-10-27 19:44:29 UTC) #22
rsc
12 years, 5 months ago (2011-10-28 01:04:18 UTC) #23
*** Submitted as http://code.google.com/p/go/source/detail?r=d51031a1d932 ***

runtime: lock the main goroutine to the main OS thread during init

We only guarantee that the main goroutine runs on the
main OS thread for initialization.  Programs that wish to
preserve that property for main.main can call runtime.LockOSThread.
This is what programs used to do before we unleashed
goroutines during init, so it is both a simple fix and keeps
existing programs working.

R=iant, r, dave, dvyukov
CC=golang-dev
http://codereview.appspot.com/5309070
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b