Created
August 19, 2019 09:05
-
-
Save ipcjk/70c1a872d180776ae7050e9886371ed0 to your computer and use it in GitHub Desktop.
golang syscall set real time priority for task
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" | |
"syscall" | |
"unsafe" | |
) | |
const ( | |
SCHED_NORMAL = iota | |
SCHED_FIFO | |
SCHED_RR | |
SCHED_BATCH | |
SCHED_ISO | |
SCHED_IDLE | |
SCHED_DEADLINE | |
) | |
func main() { | |
pid := syscall.Getpid() | |
fmt.Println("Process id is", pid) | |
fmt.Println("Scheduler vorher:") | |
syscall.Syscall(145, uintptr(0), 0, 0) | |
var schedParam uint32 = 9 | |
var schedType = SCHED_FIFO | |
_, _, err := syscall.Syscall(uintptr(144), uintptr(0), uintptr(schedType), uintptr(unsafe.Pointer(&schedParam))) | |
fmt.Println("Scheduler setzen", err) | |
fmt.Println("Scheduler nachher:") | |
syscall.Syscall(145, uintptr(0), 0, 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment