Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
2572ca2f
Commit
2572ca2f
authored
Oct 25, 2011
by
Hector Chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: include bootstrap m in mcpu accounting
R=rsc, dvyukov CC=golang-dev
https://golang.org/cl/5307052
parent
d72267ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
proc.c
src/pkg/runtime/proc.c
+11
-0
No files found.
src/pkg/runtime/proc.c
View file @
2572ca2f
...
...
@@ -128,6 +128,8 @@ Sched runtime·sched;
int32
runtime
·
gomaxprocs
;
bool
runtime
·
singleproc
;
static
bool
canaddmcpu
(
void
);
// An m that is waiting for notewakeup(&m->havenextg). This may
// only be accessed while the scheduler lock is held. This is used to
// minimize the number of times we call notewakeup while the scheduler
...
...
@@ -202,6 +204,10 @@ runtime·schedinit(void)
setmcpumax
(
runtime
·
gomaxprocs
);
runtime
·
singleproc
=
runtime
·
gomaxprocs
==
1
;
canaddmcpu
();
// mcpu++ to account for bootstrap m
m
->
helpgc
=
1
;
// flag to tell schedule() to mcpu--
runtime
·
sched
.
grunning
++
;
mstats
.
enablegc
=
1
;
m
->
nomemprof
--
;
}
...
...
@@ -811,6 +817,7 @@ schedule(G *gp)
readylocked
(
gp
);
}
}
else
if
(
m
->
helpgc
)
{
// Bootstrap m or new m started by starttheworld.
// atomic { mcpu-- }
v
=
runtime
·
xadd
(
&
runtime
·
sched
.
atomic
,
-
1
<<
mcpuShift
);
if
(
atomic_mcpu
(
v
)
>
maxgomaxprocs
)
...
...
@@ -818,6 +825,10 @@ schedule(G *gp)
// Compensate for increment in starttheworld().
runtime
·
sched
.
grunning
--
;
m
->
helpgc
=
0
;
}
else
if
(
m
->
nextg
!=
nil
)
{
// New m started by matchmg.
}
else
{
runtime
·
throw
(
"invalid m state in scheduler"
);
}
// Find (or wait for) g to run. Unlocks runtime·sched.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment