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

Delta Between Two Patch Sets: src/pkg/runtime/proc.go

Issue 132960044: code review 132960044: runtime: changes to g->atomicstatus (nee status) to sup... (Closed)
Left Patch Set: diff -r 47de34bbcca11cd65f683dc7ab0d1c6f088d25f6 https://code.google.com/p/go/ Created 10 years, 6 months ago
Right Patch Set: diff -r 53cc52c4a1dec1ea8ad862af822d1478b24f3d52 https://code.google.com/p/go/ Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/proc.c ('k') | src/pkg/runtime/runtime.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package runtime 5 package runtime
6 6
7 import "unsafe" 7 import "unsafe"
8 8
9 // This is not mechanically generated 9 // This is not mechanically generated
10 // so be very careful and refer to runtime.h 10 // so be very careful and refer to runtime.h
11 // for the definitive enum. 11 // for the definitive enum.
12 const ( 12 const (
13 gStatusidle = iota 13 gStatusidle = iota
14 gStatusRunnable 14 gStatusRunnable
15 gStatusRunning 15 gStatusRunning
16 gStatusSyscall 16 gStatusSyscall
17 gStatusWaiting 17 gStatusWaiting
18 gStatusMoribundUnused 18 gStatusMoribundUnused
19 gStatusDead 19 gStatusDead
20 » gStatusScanidle 20 » gStatusEnqueue
21 » gStatusScanrunnable
22 » gStatusScanrunning
23 » gStatusScanenqueue
24 » gStatusScansyscall
25 » gStatusScanwaiting
26 gStatusCopystack 21 gStatusCopystack
22 gStatusScan = 0x1000
23 gStatusScanRunnable = gStatusScan + gStatusRunnable
24 gStatusScanRunning = gStatusScan + gStatusRunning
25 gStatusScanSyscall = gStatusScan + gStatusSyscall
26 gStatusScanWaiting = gStatusScan + gStatusWaiting
27 gStatusScanEnqueue = gStatusScan + gStatusEnqueue
27 ) 28 )
28 29
29 var parkunlock_c byte 30 var parkunlock_c byte
30 31
31 // Gosched yields the processor, allowing other goroutines to run. It does not 32 // Gosched yields the processor, allowing other goroutines to run. It does not
32 // suspend the current goroutine, so execution resumes automatically. 33 // suspend the current goroutine, so execution resumes automatically.
33 func Gosched() { 34 func Gosched() {
34 mcall(&gosched_m) 35 mcall(&gosched_m)
35 } 36 }
36 37
37 func readgStatus(gp *g) uint32 { 38 func readgStatus(gp *g) uint32 {
38 //return atomic.LoadUint32(&gp.atomicstatus) // TODO: add bootstrap code to provide. 39 //return atomic.LoadUint32(&gp.atomicstatus) // TODO: add bootstrap code to provide.
39 return gp.atomicstatus 40 return gp.atomicstatus
dvyukov 2014/08/27 13:16:03 we have goatomicload function
rlh 2014/08/27 15:15:53 There are (or were as of yesterday) some bootstrap
40 } 41 }
41 42
42 // Puts the current goroutine into a waiting state and calls unlockf. 43 // Puts the current goroutine into a waiting state and calls unlockf.
43 // If unlockf returns false, the goroutine is resumed. 44 // If unlockf returns false, the goroutine is resumed.
44 func gopark(unlockf unsafe.Pointer, lock unsafe.Pointer, reason string) { 45 func gopark(unlockf unsafe.Pointer, lock unsafe.Pointer, reason string) {
45 mp := acquirem() 46 mp := acquirem()
46 gp := mp.curg 47 gp := mp.curg
47 status := readgStatus(gp) 48 status := readgStatus(gp)
48 » if status != gStatusRunning && status != gStatusScanrunning { 49 » if status != gStatusRunning && status != gStatusScanRunning {
49 gothrow("gopark: bad g status") 50 gothrow("gopark: bad g status")
50 } 51 }
51 mp.waitlock = lock 52 mp.waitlock = lock
52 mp.waitunlockf = *(*func(*g, unsafe.Pointer) uint8)(unsafe.Pointer(&unlo ckf)) 53 mp.waitunlockf = *(*func(*g, unsafe.Pointer) uint8)(unsafe.Pointer(&unlo ckf))
53 gp.waitreason = reason 54 gp.waitreason = reason
54 releasem(mp) 55 releasem(mp)
55 // can't do anything that might move the G between Ms here. 56 // can't do anything that might move the G between Ms here.
56 mcall(&park_m) 57 mcall(&park_m)
57 } 58 }
58 59
(...skipping 30 matching lines...) Expand all
89 } 90 }
90 return new(sudog) 91 return new(sudog)
91 } 92 }
92 93
93 //go:nosplit 94 //go:nosplit
94 func releaseSudog(s *sudog) { 95 func releaseSudog(s *sudog) {
95 c := gomcache() 96 c := gomcache()
96 s.next = c.sudogcache 97 s.next = c.sudogcache
97 c.sudogcache = s 98 c.sudogcache = s
98 } 99 }
LEFTRIGHT

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