Created
October 2, 2015 21:00
-
-
Save yifan-gu/af16d1fbafd07d9e8e67 to your computer and use it in GitHub Desktop.
testsyscall.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"syscall" | |
"time" | |
) | |
import "runtime" | |
func main() { | |
fmt.Println("pid", os.Getpid()) | |
done := make(chan struct{}) | |
go func() { | |
fmt.Println("goroutine tid", syscall.Gettid()) | |
runtime.LockOSThread() | |
time.Sleep(time.Second * 10) | |
fmt.Println("go routine exit...") | |
time.Sleep(time.Second * 2) | |
close(done) | |
syscall.Syscall(syscall.SYS_EXIT, uintptr(0), 0, 0) | |
}() | |
<-done | |
fmt.Println("done", os.Getpid()) | |
for { | |
runtime.Gosched() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment