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
eb48bfbb
Commit
eb48bfbb
authored
May 06, 2010
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime.GOMAXPROCS: hack it to have it return the old value.
R=rsc CC=golang-dev
https://golang.org/cl/1140041
parent
9088f9f2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
7 deletions
+16
-7
extern.go
src/pkg/runtime/extern.go
+4
-2
proc.c
src/pkg/runtime/proc.c
+8
-5
runtime.h
src/pkg/runtime/runtime.h
+1
-0
runtime1.goc
src/pkg/runtime/runtime1.goc
+3
-0
No files found.
src/pkg/runtime/extern.go
View file @
eb48bfbb
...
...
@@ -106,8 +106,10 @@ func LockOSThread()
func
UnlockOSThread
()
// GOMAXPROCS sets the maximum number of CPUs that can be executing
// simultaneously. This call will go away when the scheduler improves.
func
GOMAXPROCS
(
n
int
)
// simultaneously and returns the previous setting. If n < 1, it does not
// change the current setting.
// This call will go away when the scheduler improves.
func
GOMAXPROCS
(
n
int
)
int
// Cgocalls returns the number of cgo calls made by the current process.
func
Cgocalls
()
int64
...
...
src/pkg/runtime/proc.c
View file @
eb48bfbb
...
...
@@ -1136,13 +1136,15 @@ void
}
// delete when scheduler is stronger
void
·
GOMAXPROCS
(
int32
n
)
int32
gomaxprocsfunc
(
int32
n
)
{
if
(
n
<
1
)
n
=
1
;
int32
ret
;
lock
(
&
sched
);
ret
=
sched
.
gomaxprocs
;
if
(
n
<=
0
)
n
=
ret
;
sched
.
gomaxprocs
=
n
;
sched
.
mcpumax
=
n
;
// handle fewer procs?
...
...
@@ -1152,11 +1154,12 @@ void
// we'll only get rescheduled once the
// number has come down.
gosched
();
return
;
return
ret
;
}
// handle more procs
matchmg
();
unlock
(
&
sched
);
return
ret
;
}
void
...
...
src/pkg/runtime/runtime.h
View file @
eb48bfbb
...
...
@@ -569,6 +569,7 @@ float64 modf(float64 d, float64 *ip);
void
semacquire
(
uint32
*
);
void
semrelease
(
uint32
*
);
String
signame
(
int32
sig
);
int32
gomaxprocsfunc
(
int32
n
);
void
mapassign
(
Hmap
*
,
byte
*
,
byte
*
);
...
...
src/pkg/runtime/runtime1.goc
View file @
eb48bfbb
...
...
@@ -9,3 +9,6 @@ func mal(n uint32) (ret *uint8) {
ret
=
mal
(
n
);
}
func
GOMAXPROCS
(
n
int32
)
(
ret
int32
)
{
ret
=
gomaxprocsfunc
(
n
);
}
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