コード例 #1
0
func SetPriorityThreadGroup(threads *ThreadList) error {
	for _, t := range *threads {
		if !t.HasPolicy {
			continue
		}
		if err := unix.Setpriority(unix.PRIO_PROCESS, t.Tid, t.Prio); err != nil {
			return err
		}
	}
	return nil
}
コード例 #2
0
func RescheduleThreadGroup(threads *ThreadList) error {
	for _, t := range *threads {
		if !t.HasPolicy {
			continue
		}
		if len(t.Cpus) == 0 {
			t.Cpus = NewCpuPool(runtime.NumCPU())
		}
		fmt.Println("Pinning thread", t.Name, "to CPU set", t.Cpus)
		if err := SetAffinity(t.Tid, t.Cpus); err != nil {
			return err
		}
		fmt.Println("Setting thread", t.Name, "priority to", t.Prio)
		if err1 := unix.Setpriority(unix.PRIO_PROCESS, t.Tid, t.Prio); err1 != nil {
			return err1
		}
	}
	return nil
}