PTHREAD_A...CHEDPARAM(3P)
π PTHREAD_A...CHEDPARAM(3P) β POSIX Programmer's Manual π
okay bestie, welcome to the page for pthread_attr_getschedparam and pthread_attr_setschedparam β it lives in the POSIX Programmer's Manual, section 3P, and it's all about reading and writing the schedparam attribute on a thread attributes object. π
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual, no cap. β οΈ But heads up: the Linux implementation of this interface may differ (so go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. π
πΈ NAME πΈ
pthread_attr_getschedparam, pthread_attr_setschedparam β get and set the schedparam attribute π«Ά
β¨ SYNOPSIS β¨
#include <pthread.h>
int pthread_attr_getschedparam(const pthread_attr_t *restrict attr,
struct sched_param *restrict param);
int pthread_attr_setschedparam(pthread_attr_t *restrict attr,
const struct sched_param *restrict param);
π DESCRIPTION π
So pthread_attr_getschedparam() and pthread_attr_setschedparam() respectively get and set the scheduling parameter attributes inside the attr argument. That's the whole vibe. π
The contents of the param structure are defined in the <sched.h> header. For the SCHED_FIFO and SCHED_RR policies, the only required member of param is sched_priority. iconic, minimal, we love. β
Now for the SCHED_SPORADIC policy, the required members of the param structure are:
sched_prioritysched_ss_low_prioritysched_ss_repl_periodsched_ss_init_budgetsched_ss_max_repl
The specified sched_ss_repl_period must be greater than or equal to the specified sched_ss_init_budget for the function to succeed β if it's not, then the function shall fail. π The value of sched_ss_max_repl shall be within the inclusive range [1,{SS_REPL_MAX}] for the function to succeed; if not, the function shall fail. π¨
Also, it is unspecified whether the sched_ss_repl_period and sched_ss_init_budget values are stored exactly as provided by this function, or get rounded to align with the resolution of the clock being used. so don't come for me about the rounding, it's just undefined-ish like that. π
π The behavior is undefined if the value specified by theattrargument topthread_attr_getschedparam()orpthread_attr_setschedparam()does not refer to an initialized thread attributes object. like, undefined undefined. don't do it.
π RETURN VALUE π
If successful, both pthread_attr_getschedparam() and pthread_attr_setschedparam() shall return zero. Otherwise, an error number shall be returned to indicate the error. slay when it's zero, sad when it's not. π
π₯ ERRORS π₯
The pthread_attr_setschedparam() function shall fail if:
ENOTSUPβ An attempt was made to set the attribute to an unsupported value. π€
The pthread_attr_setschedparam() function may fail if:
EINVALβ The value ofparamis not valid. π
These functions shall not return an error code of [EINTR]. periodt. β
The following sections are informative. (aka the tea is optional but still delicious π)
π§ EXAMPLES π§
None. π literally nothing. we're on our own bestie.
π APPLICATION USAGE π
After these attributes have been set, a thread can be created with the specified attributes using pthread_create(). π
Using these routines does not affect the current running thread. so nobody's getting jumpscared by their own scheduling changing mid-sentence. π
π¦ RATIONALE π¦
If an implementation detects that the value specified by the attr argument to pthread_attr_getschedparam() or pthread_attr_setschedparam() does not refer to an initialized thread attributes object, it is recommended that the function should fail and report an [EINVAL] error. that's the polite thing to do fr fr. π
β FUTURE DIRECTIONS β
None. β¨ the future is bright and also empty.
π SEE ALSO π
pthread_attr_destroy()pthread_attr_getscope()pthread_attr_getinheritsched()pthread_attr_getschedpolicy()pthread_create()
The Base Definitions volume of POSIX.1β2017, <pthread.h>, <sched.h> π
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie π β¨ this one was published by IEEE/The Open Group back in 2017, so if you're citing it, you know exactly who to credit π«Ά mwah, go schedule something responsibly π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms