Skip to content

Instantly share code, notes, and snippets.

@yifan-gu
Created October 2, 2015 21:00
Show Gist options
  • Save yifan-gu/af16d1fbafd07d9e8e67 to your computer and use it in GitHub Desktop.
Save yifan-gu/af16d1fbafd07d9e8e67 to your computer and use it in GitHub Desktop.
testsyscall.go
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