Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
3611553c
Commit
3611553c
authored
Mar 01, 2013
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: add atomics to fix arm
R=golang-dev, minux.ma CC=golang-dev
https://golang.org/cl/7429046
parent
f42a11ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
src/pkg/runtime/proc.c
src/pkg/runtime/proc.c
+17
-17
src/pkg/runtime/runtime.h
src/pkg/runtime/runtime.h
+1
-1
No files found.
src/pkg/runtime/proc.c
View file @
3611553c
...
...
@@ -45,7 +45,7 @@ struct Sched {
int32
stopwait
;
Note
stopnote
;
bool
sysmonwait
;
uint32
sysmonwait
;
Note
sysmonnote
;
int32
profilehz
;
// cpu profiling rate
...
...
@@ -59,7 +59,7 @@ Sched runtime·sched;
int32
runtime
·
gomaxprocs
;
bool
runtime
·
singleproc
;
bool
runtime
·
iscgo
;
int32
runtime
·
gcwaiting
;
u
int32
runtime
·
gcwaiting
;
M
runtime
·
m0
;
G
runtime
·
g0
;
// idle goroutine for m0
G
*
runtime
·
allg
;
...
...
@@ -277,7 +277,7 @@ runtime·ready(G *gp)
}
gp
->
status
=
Grunnable
;
runqput
(
m
->
p
,
gp
);
if
(
runtime
·
sched
.
npidle
!=
0
&&
runtime
·
sched
.
nmspinning
==
0
)
// TODO: fast atomic
if
(
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
!=
0
&&
runtime
·
atomicload
(
&
runtime
·
sched
.
nmspinning
)
==
0
)
// TODO: fast atomic
wakep
();
}
...
...
@@ -842,7 +842,7 @@ handoffp(P *p)
}
// no local work, check that there are no spinning/idle M's,
// otherwise our help is not required
if
(
runtime
·
sched
.
nmspinning
+
runtime
·
sched
.
npidle
==
0
&&
// TODO: fast atomic
if
(
runtime
·
atomicload
(
&
runtime
·
sched
.
nmspinning
)
+
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
==
0
&&
// TODO: fast atomic
runtime
·
cas
(
&
runtime
·
sched
.
nmspinning
,
0
,
1
))
{
startm
(
p
,
true
);
return
;
...
...
@@ -996,7 +996,7 @@ top:
// If number of spinning M's >= number of busy P's, block.
// This is necessary to prevent excessive CPU consumption
// when GOMAXPROCS>>1 but the program parallelism is low.
if
(
!
m
->
spinning
&&
2
*
runtime
·
sched
.
nmspinning
>=
runtime
·
gomaxprocs
-
runtime
·
sched
.
npidle
)
// TODO: fast atomic
if
(
!
m
->
spinning
&&
2
*
runtime
·
atomicload
(
&
runtime
·
sched
.
nmspinning
)
>=
runtime
·
gomaxprocs
-
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
)
// TODO: fast atomic
goto
stop
;
if
(
!
m
->
spinning
)
{
m
->
spinning
=
true
;
...
...
@@ -1079,8 +1079,8 @@ top:
// M wakeup policy is deliberately somewhat conservative (see nmspinning handling),
// so see if we need to wakeup another M here.
if
(
m
->
p
->
runqhead
!=
m
->
p
->
runqtail
&&
runtime
·
sched
.
nmspinning
==
0
&&
runtime
·
sched
.
npidle
>
0
)
// TODO: fast atomic
runtime
·
atomicload
(
&
runtime
·
sched
.
nmspinning
)
==
0
&&
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
>
0
)
// TODO: fast atomic
wakep
();
if
(
gp
->
lockedm
)
{
...
...
@@ -1197,10 +1197,10 @@ void
runtime
·
throw
(
"entersyscall"
);
}
if
(
runtime
·
sched
.
sysmonwait
)
{
// TODO: fast atomic
if
(
runtime
·
atomicload
(
&
runtime
·
sched
.
sysmonwait
)
)
{
// TODO: fast atomic
runtime
·
lock
(
&
runtime
·
sched
);
if
(
runtime
·
sched
.
sysmonwait
)
{
runtime
·
sched
.
sysmonwait
=
false
;
if
(
runtime
·
atomicload
(
&
runtime
·
sched
.
sysmonwait
)
)
{
runtime
·
atomicstore
(
&
runtime
·
sched
.
sysmonwait
,
0
)
;
runtime
·
notewakeup
(
&
runtime
·
sched
.
sysmonnote
);
}
runtime
·
unlock
(
&
runtime
·
sched
);
...
...
@@ -1457,7 +1457,7 @@ runtime·newproc1(FuncVal *fn, byte *argp, int32 narg, int32 nret, void *callerp
newg
->
racectx
=
runtime
·
racegostart
(
callerpc
);
runqput
(
m
->
p
,
newg
);
if
(
runtime
·
sched
.
npidle
!=
0
&&
runtime
·
sched
.
nmspinning
==
0
&&
fn
->
fn
!=
runtime
·
main
)
// TODO: fast atomic
if
(
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
!=
0
&&
runtime
·
atomicload
(
&
runtime
·
sched
.
nmspinning
)
==
0
&&
fn
->
fn
!=
runtime
·
main
)
// TODO: fast atomic
wakep
();
return
newg
;
}
...
...
@@ -1915,10 +1915,10 @@ sysmon(void)
if
(
delay
>
10
*
1000
)
// up to 10ms
delay
=
10
*
1000
;
runtime
·
usleep
(
delay
);
if
(
runtime
·
gcwaiting
||
runtime
·
sched
.
npidle
==
runtime
·
gomaxprocs
)
{
// TODO: fast atomic
if
(
runtime
·
gcwaiting
||
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
==
runtime
·
gomaxprocs
)
{
// TODO: fast atomic
runtime
·
lock
(
&
runtime
·
sched
);
if
(
runtime
·
gcwaiting
||
runtime
·
sched
.
npidle
==
runtime
·
gomaxprocs
)
{
runtime
·
sched
.
sysmonwait
=
true
;
if
(
runtime
·
atomicload
(
&
runtime
·
gcwaiting
)
||
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
==
runtime
·
gomaxprocs
)
{
runtime
·
atomicstore
(
&
runtime
·
sched
.
sysmonwait
,
1
)
;
runtime
·
unlock
(
&
runtime
·
sched
);
runtime
·
notesleep
(
&
runtime
·
sched
.
sysmonnote
);
runtime
·
noteclear
(
&
runtime
·
sched
.
sysmonnote
);
...
...
@@ -1954,7 +1954,7 @@ retake(uint32 *ticks)
s
=
p
->
status
;
if
(
s
!=
Psyscall
)
continue
;
if
(
p
->
runqhead
==
p
->
runqtail
&&
runtime
·
sched
.
nmspinning
+
runtime
·
sched
.
npidle
>
0
)
// TODO: fast atomic
if
(
p
->
runqhead
==
p
->
runqtail
&&
runtime
·
atomicload
(
&
runtime
·
sched
.
nmspinning
)
+
runtime
·
atomicload
(
&
runtime
·
sched
.
npidle
)
>
0
)
// TODO: fast atomic
continue
;
// Need to increment number of locked M's before the CAS.
// Otherwise the M from which we retake can exit the syscall,
...
...
@@ -2042,7 +2042,7 @@ pidleput(P *p)
{
p
->
link
=
runtime
·
sched
.
pidle
;
runtime
·
sched
.
pidle
=
p
;
runtime
·
sched
.
npidle
++
;
// TODO: fast atomic
runtime
·
xadd
(
&
runtime
·
sched
.
npidle
,
1
)
;
// TODO: fast atomic
}
// Try get a p from pidle list.
...
...
@@ -2055,7 +2055,7 @@ pidleget(void)
p
=
runtime
·
sched
.
pidle
;
if
(
p
)
{
runtime
·
sched
.
pidle
=
p
->
link
;
runtime
·
sched
.
npidle
--
;
// TODO: fast atomic
runtime
·
xadd
(
&
runtime
·
sched
.
npidle
,
-
1
)
;
// TODO: fast atomic
}
return
p
;
}
...
...
src/pkg/runtime/runtime.h
View file @
3611553c
...
...
@@ -628,7 +628,7 @@ extern P** runtime·allp;
extern
int32
runtime
·
gomaxprocs
;
extern
bool
runtime
·
singleproc
;
extern
uint32
runtime
·
panicking
;
extern
int32
runtime
·
gcwaiting
;
// gc is waiting to run
extern
u
int32
runtime
·
gcwaiting
;
// gc is waiting to run
extern
int8
*
runtime
·
goos
;
extern
int32
runtime
·
ncpu
;
extern
bool
runtime
·
iscgo
;
...
...
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