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
43c6e810
Commit
43c6e810
authored
Sep 08, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X runtime.GetCPU()
This way one can verify on which physical CPU the code is currently running.
parent
ab401077
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
src/runtime/stubs_linux.go
src/runtime/stubs_linux.go
+10
-0
src/runtime/sys_linux_amd64.s
src/runtime/sys_linux_amd64.s
+11
-0
No files found.
src/runtime/stubs_linux.go
View file @
43c6e810
...
...
@@ -7,3 +7,13 @@
package
runtime
func
sbrk0
()
uintptr
func
_getcpu
()
(
cpu
,
node
uint32
,
ret
int32
)
func
GetCPU
()
(
cpu
,
node
uint32
)
{
cpu
,
node
,
ret
:=
_getcpu
()
//println("_getcpu ->", cpu, node, ret)
if
ret
!=
0
{
throw
(
"getcpu failed"
)
}
return
cpu
,
node
}
src/runtime/sys_linux_amd64.s
View file @
43c6e810
...
...
@@ -45,6 +45,7 @@
#define SYS_epoll_ctl 233
#define SYS_pselect6 270
#define SYS_epoll_create1 291
#define SYS_getcpu 309
TEXT
runtime
·
exit
(
SB
),
NOSPLIT
,$0-4
MOVL
code
+
0
(
FP
),
DI
...
...
@@ -659,3 +660,13 @@ TEXT runtime·sbrk0(SB),NOSPLIT,$0-8
SYSCALL
MOVQ
AX
,
ret
+
0
(
FP
)
RET
//
func
_getcpu
()
(
cpu
,
node
uint32
,
ret
int32
)
TEXT
runtime
·
_getcpu
(
SB
),
NOSPLIT
,$0
LEAQ
cpu
+
0
(
FP
),
DI
LEAQ
node
+
4
(
FP
),
SI
XORQ
DX
,
DX
//
tcache
MOVL
$SYS_getcpu
,
AX
SYSCALL
MOVL
AX
,
ret
+
8
(
FP
)
RET
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