sched_setattr(2) System Calls Manual sched_setattr(2) sched_setattr, sched_getattr - (libc -lc) #include /* Definition of SCHED_* constants */ #include /* Definition of SYS_* constants */ #include int syscall(SYS_sched_setattr, pid_t pid, struct sched_attr *attr, unsigned int flags); int syscall(SYS_sched_getattr, pid_t pid, struct sched_attr *attr, unsigned int size, unsigned int flags); : glibc syscall(2). sched_setattr() sched_setattr() pid. pid . "" ( ) policy: SCHED_OTHER (round-robin) SCHED_BATCH "" SCHED_IDLE . " " . sched(7). policy : SCHED_FIFO SCHED_RR (round-robin). : SCHED_DEADLINE sched(7) . attr . : struct sched_attr { u32 size; /* Size of this structure */ u32 sched_policy; /* Policy (SCHED_*) */ u64 sched_flags; /* Flags */ s32 sched_nice; /* Nice value (SCHED_OTHER, SCHED_BATCH) */ u32 sched_priority; /* Static priority (SCHED_FIFO, SCHED_RR) */ /* For SCHED_DEADLINE */ u64 sched_runtime; u64 sched_deadline; u64 sched_period; /* Utilization hints */ u32 sched_util_min; u32 sched_util_max; }; sched_attr : size sizeof(struct sched_attr). '0'. 0 sched_setattr() E2BIG size . sched_attr . sched_attr . sched_attr . sched_policy SCHED_* . sched_flags OR : SCHED_FLAG_RESET_ON_FORK fork(2) . sched(7) . SCHED_FLAG_RECLAIM ( 4.13) SCHED_DEADLINE . SCHED_FLAG_DL_OVERRUN ( 4.16) SCHED_DEADLINE. ( ) . SIGXCPU . SIGXCPU ( signal(7)) . . sched_setattr() . . SCHED_FLAG_UTIL_CLAMP_MIN SCHED_FLAG_UTIL_CLAMP_MAX ( 5.3) sched_util_min sched_util_max . . sched_nice sched_policy SCHED_OTHER SCHED_BATCH. -20 ( ) +19 ( ) sched(7). sched_priority sched_policy SCHED_FIFO SCHED_RR. sched_get_priority_min(2) sched_get_priority_max(2). 0. sched_runtime "Runtime" . . SCHED_DEADLINE sched(7). sched_deadline "Deadline" . . sched_period "Period" . . sched_util_min sched_util_max ( 5.3) . SCHED_FLAG_UTIL_CLAMP_MIN SCHED_FLAG_UTIL_CLAMP_MAX sched_flags. [0, 1024] . 1024 100% 0 0%. 20% 2 10 0.2 * 1024 = 205. 0 . 1024 . UINT32_MAX ( 5.11). flags 0. sched_getattr() sched_getattr() pid. pid . size sched_attr . sched_attr EINVAL. sched_attr attr. attr.size sched_attr . attr sched_attr . sched_attr . sched_setattr() . flags 0. sched_setattr() sched_getattr() 0. -1 errno . sched_getattr() sched_setattr() : EINVAL attr NULL pid flags . ESRCH (thread) pid. sched_getattr() : E2BIG size attr . EINVAL size sched_attr (48 ) . sched_setattr() : E2BIG size attr . EBUSY SCHED_DEADLINE sched(7). EINVAL attr.sched_policy . EINVAL attr.sched_flags SCHED_FLAG_RESET_ON_FORK. EINVAL attr.sched_priority . EINVAL attr.sched_policy SCHED_DEADLINE attr . EINVAL attr.sched_flags SCHED_FLAG_UTIL_CLAMP_MIN SCHED_FLAG_UTIL_CLAMP_MAX attr.sched_util_min attr.sched_util_max . EOPNOTSUPP SCHED_FLAG_UTIL_CLAMP CONFIG_UCLAMP_TASK. EPERM . EPERM pid ( sched_setaffinity(2)). . 3.14. glibc syscall(2). sched_setattr() sched_setscheduler(2) sched_setparam(2) nice(2) ( ) setpriority(2). sched_getattr() sched_getscheduler(2) sched_getparam(2) () getpriority(2). 3.15 sched_setattr() EFAULT E2BIG . 5.3 sched_getattr() EFBIG sched_attr size . chrt(1), nice(2), sched_get_priority_max(2), sched_get_priority_min(2), sched_getaffinity(2), sched_getparam(2), sched_getscheduler(2), sched_rr_get_interval(2), sched_setaffinity(2), sched_setparam(2), sched_setscheduler(2), sched_yield(2), setpriority(2), pthread_getschedparam(3), pthread_setschedparam(3), pthread_setschedprio(3), capabilities(7), cpuset(7), sched(7) 3 . . : . 6.18 8 2026 sched_setattr(2)