26 lines
425 B
Go
26 lines
425 B
Go
package main
|
|
|
|
/*
|
|
#ifndef _GNU_SOURCE
|
|
#define _GNU_SOURCE // SCHED_IDLE
|
|
#endif
|
|
|
|
#include <sched.h>
|
|
|
|
const struct sched_param param = { .sched_priority = 0 };
|
|
const int NIX_TOOL_SCHED_IDLE = SCHED_IDLE;
|
|
*/
|
|
import "C"
|
|
|
|
var (
|
|
SCHED_IDLE = int(C.NIX_TOOL_SCHED_IDLE)
|
|
)
|
|
|
|
func schedSetPolicy(pid, policy int) error {
|
|
r, err := C.sched_setscheduler(C.pid_t(pid), C.int(policy), &C.param)
|
|
if r != 0 {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|