42 lines
924 B
Go
42 lines
924 B
Go
//go:build !linux
|
|
|
|
package client
|
|
|
|
func set_affinity(pid int, cpu int) {
|
|
|
|
}
|
|
|
|
// package main
|
|
|
|
// import (
|
|
// "fmt"
|
|
// "syscall"
|
|
// "time"
|
|
// "unsafe"
|
|
// )
|
|
|
|
// func main() {
|
|
// var mask uintptr
|
|
|
|
// // Get the current CPU affinity of the process
|
|
// if _, _, err := syscall.RawSyscall(syscall.SYS_SCHED_GETAFFINITY, 0, uintptr(unsafe.Sizeof(mask)), uintptr(unsafe.Pointer(&mask))); err != 0 {
|
|
// fmt.Println("Failed to get CPU affinity:", err)
|
|
// return
|
|
// }
|
|
// fmt.Println("Current CPU affinity:", mask)
|
|
|
|
// // Set the new CPU affinity
|
|
// mask = 3
|
|
// if _, _, err := syscall.RawSyscall(syscall.SYS_SCHED_SETAFFINITY, 0, uintptr(unsafe.Sizeof(mask)), uintptr(unsafe.Pointer(&mask))); err != 0 {
|
|
// fmt.Println("Failed to set CPU affinity:", err)
|
|
// return
|
|
// }
|
|
// fmt.Println("New CPU affinity:", mask)
|
|
|
|
// // some code
|
|
// for {
|
|
// println("Hello, World!")
|
|
// time.Sleep(1 * time.Second)
|
|
// }
|
|
// }
|