github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/sync2/runtime2/pid.go (about)

     1  package runtime2
     2  
     3  import _ "unsafe"
     4  
     5  func ProcessorHint() int { return int(runtime_pid()) }
     6  
     7  // func pid() uint32 {
     8  // 	return getg().m.p.ptr().id
     9  // }
    10  
    11  //go:linkname procPin runtime.procPin
    12  //go:nosplit
    13  func procPin() int
    14  
    15  //go:linkname procUnpin runtime.procUnpin
    16  //go:nosplit
    17  func procUnpin()
    18  
    19  func runtime_pid() int {
    20  	pid := procPin()
    21  	procUnpin()
    22  	return pid
    23  }
    24  
    25  func asm_pid() uint32
    26  
    27  func rdtscp_pid() int
    28  func rdpid_pid() int
    29  func cpuid_pid() int