PTHREAD...EDPARAM(3POSIX)
๐ PTHREAD...EDPARAM(3POSIX) โ the POSIX Programmer's Manual, bestie edition ๐
okay so first things first, real talk: this page lives in the POSIX Programmer's Manual, and there's a little โจdisclaimerโจ you need to know before we get into it.
โ ๏ธ Heads up babes: this manual page is part of the POSIX Programmer's Manual. 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 be implemented on Linux at all. Not every baddie is available everywhere, iykyk. ๐
โจ 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 basically, pthread_attr_getschedparam() and pthread_attr_setschedparam() do exactly what it says on the tin, bestie โ they get and set the scheduling parameter attributes inside that attr argument. ๐ฅ๐ค
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. That's it, that's the whole requirement. simple. iconic. โจ
For the SCHED_SPORADIC policy though? Now we're in our main character era, and the required members of the param structure are:
sched_prioritysched_ss_low_prioritysched_ss_repl_periodsched_ss_init_budgetsched_ss_max_repl
and there are rules, okay? listen up ๐ซถ
- The specified
sched_ss_repl_periodmust be greater than or equal to the specifiedsched_ss_init_budgetfor the function to succeed. If it is not โ the function shall fail. no cap. - The value of
sched_ss_max_replshall be within the inclusive range[1,{SS_REPL_MAX}]for the function to succeed. If not โ yeah, the function shall fail. ๐ญ - It is unspecified whether the
sched_ss_repl_periodandsched_ss_init_budgetvalues are stored exactly as provided by this function, or are rounded to align with the resolution of the clock being used. so don't come for us if it's a little off-grid. ๐
๐ undefined behavior alert ๐ 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, don't do that. Please. ๐
๐ RETURN VALUE ๐
If it's giving success? Both pthread_attr_getschedparam() and pthread_attr_setschedparam() shall return zero. ๐
Otherwise? An error number shall be returned to indicate the error. that's it, that's the vibe check. โ โ
๐ฅ ERRORS ๐ฅ
The pthread_attr_setschedparam() function shall fail if:
ENOTSUPโ An attempt was made to set the attribute to an unsupported value. ๐ค not supported, not the vibe.
The pthread_attr_setschedparam() function may fail if:
EINVALโ The value ofparamis not valid. ๐ซ
๐ also super important: these functions shall not return an error code of [EINTR]. like, that one's just not happening, periodt.
The following sections are informative. ๐ (yes girl, we're in the informational zone now)
๐ EXAMPLES ๐
None. ๐ nothing to see here, moving on bestie.
๐ฆ APPLICATION USAGE ๐ฆ
After these attributes have been set, a thread can be created with the specified attributes using pthread_create(). ๐งตโจ
And real quick โ using these routines does not affect the current running thread. so your main character stays exactly as she is, no side effects, we love to see it. ๐
๐ 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. like, just be honest about it, y'know? ๐ซถ
โญ FUTURE DIRECTIONS โญ
None. ๐ฎ the future is... empty. slay.
๐ 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 came from IEEE/The Open Group, 2017 (the PTHREAD...EDPARAM(3POSIX) page, if you're keeping track ๐). go forth and schedule your threads responsibly, mwah ๐โจ๐ฆ
๐ฆ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms