sched_setattr(2) System Calls Manual sched_setattr(2) sched_setattr, sched_getattr - LIBRARY Standard C library (libc, -lc) #include /* SCHED_* */ #include /* SYS_* */ #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); Note: glibc provides no wrappers for these system calls, necessitating the use of syscall(2). sched_setattr() sched_setattr() pid. pid , . Linux <<>> (. . ) , policy: SCHED_OTHER ; SCHED_BATCH <<>> ; SCHED_IDLE . << >>, , , . , , sched(7). , policy: SCHED_FIFO << -- >>; SCHED_RR . Linux : SCHED_DEADLINE ; sched(7). attr , , . : struct sched_attr { u32 size; /* */ u32 sched_policy; /* (SCHED_*) */ u64 sched_flags; /* */ s32 sched_nice; /* (SCHED_OTHER, SCHED_BATCH) */ u32 sched_priority; /* (SCHED_FIFO, SCHED_RR) */ /* SCHED_DEADLINE */ u64 sched_runtime; u64 sched_deadline; u64 sched_period; }; sched_attr: size sizeof(struct sched_attr). , , <<0>>. , , 0; , sched_setattr() E2BIG size . sched_attr . , , , sched_attr. , , sched_attr , , , . sched_policy SCHED_*, . sched_flags , : SCHED_FLAG_RESET_ON_FORK , fork(2), . sched(7). SCHED_FLAG_RECLAIM ( Linux 4.13) SCHED_DEADLINE , . SCHED_FLAG_DL_OVERRUN ( Linux 4.16) (run-time overrun) SCHED_DEADLINE. () . SIGXCPU, . SIGXCPU ( signal(7)), . , . , sched_setattr() . , , , , , . 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 <> . . SCHED_DEADLINE; sched(7). sched_deadline <> . . sched_period <> . . flags ; 0. sched_getattr() sched_getattr() pid. pid , . size sched_attr, . sched_attr EINVAL. sched_attr, attr. attr.size sched_attr. If the caller-provided attr buffer is larger than the kernel's sched_attr structure, the additional bytes in the user-space structure are not touched. If the caller-provided structure is smaller than the kernel sched_attr structure, the kernel will silently not return any values which would be stored outside the provided space. As with sched_setattr(), these semantics allow for future extensibility of the interface. flags ; 0. On success, sched_setattr() and sched_getattr() return 0. On error, -1 is returned, and errno is set to indicate the error. sched_getattr() sched_setattr() : EINVAL attr NULL; pid ; flags 0. ESRCH 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 ; attr.sched_flags SCHED_FLAG_RESET_ON_FORK; attr.sched_priority; attr.sched_policy SCHED_DEADLINE attr. EPERM . EPERM , pid, ( sched_setaffinity(2)). Linux. Linux 3.14. glibc does not provide wrappers for these system calls; call them using syscall(2). sched_setattr() sched_setscheduler(2), sched_setparam(2), nice(2) ( , ) setpriority(2). , sched_getattr() sched_getscheduler(2), sched_getparam(2) () getpriority(2). Linux 3.15, sched_setattr() EFAULT, E2BIG , . Up to Linux 5.3, sched_getattr() failed with the error EFBIG if the in-kernel sched_attr structure was larger than the size passed by user space. . 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) Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . sched_setattr(2)