PTHREAD...ITSCHED(3POSIX)
π PTHREAD...ITSCHED(3POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual page for pthread_attr_getinheritsched and pthread_attr_setinheritsched β aka the get-and-set girlies for the inheritsched attribute. sit down, hydrate, this is REALTIME THREADS territory and we're gonna slay it together β¨
πΈ PROLOG πΈ
bestie real talk before we even start: this page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β so like, consult the corresponding Linux manual page for the details of Linux behavior, okay? or the interface might just not be implemented on Linux at all. no cap. check before you ship π«Ά
π NAME π
pthread_attr_getinheritsched, pthread_attr_setinheritsched β get and set the inheritsched attribute (REALTIME THREADS)
β¨ SYNOPSIS β¨
#include <pthread.h>
int pthread_attr_getinheritsched(const pthread_attr_t *restrict attr,
int *restrict inheritsched);
int pthread_attr_setinheritsched(pthread_attr_t *attr,
int inheritsched);
π DESCRIPTION π
so. the pthread_attr_getinheritsched() and pthread_attr_setinheritsched() functions respectively get and set the inheritsched attribute inside the attr argument. get, set, iconic, that's the whole vibe.
when the attributes objects get used by pthread_create(), the inheritsched attribute is the one that decides how the other scheduling attributes of the created thread shall be set. like it's literally the main character of scheduling-attribute decisions. periodt.
the supported values of inheritsched shall be:
PTHREAD_INHERIT_SCHEDβ says that the thread scheduling attributes shall be inherited from the creating thread, and the scheduling attributes in thisattrargument shall be ignored. like, the attr said nothing, it knows nothing, mind your business πPTHREAD_EXPLICIT_SCHEDβ says that the thread scheduling attributes shall be set to the corresponding values from this attributes object. we're being explicit, we're being deliberate, we're being that girl.
the symbols PTHREAD_INHERIT_SCHED and PTHREAD_EXPLICIT_SCHED are defined in the <pthread.h> header. π
now, the following thread scheduling attributes defined by POSIX.1β2008 are affected by the inheritsched attribute: scheduling policy (schedpolicy), scheduling parameters (schedparam), and scheduling contention scope (contentionscope). those three, right there, they're the ones in the group chat that inheritsched is texting. π¬
β οΈ ok major warning bestie: the behavior is undefined if the value specified by theattrargument topthread_attr_getinheritsched()orpthread_attr_setinheritsched()does not refer to an initialized thread attributes object. undefined. we don't do undefined. initialize your attr first, i'm begging π
π RETURN VALUE π
if everything goes well, pthread_attr_getinheritsched() and pthread_attr_setinheritsched() shall return zero π otherwise, an error number shall be returned to indicate the error. that's the deal.
π ERRORS π
the pthread_attr_setinheritsched() function shall fail if:
ENOTSUPβ an attempt was made to set the attribute to an unsupported value. like the attribute looked at your value and said "not in my house" π
the pthread_attr_setinheritsched() function may fail if:
EINVALβ the value ofinheritschedis not valid.
and listen: these functions shall not return an error code of [EINTR]. not a thing here. don't even worry about it.
the following sections are informative. (yes queen, we're going into the informative era π¦)
π EXAMPLES π
None. β literally nothing. empty. the void. we move on bestie π
πΈ APPLICATION USAGE πΈ
after these attributes have been set, a thread can be created with the specified attributes using pthread_create(). π§
and here's a lil detail people always get wrong: using these routines does not affect the current running thread. the current thread is fine. the current thread is thriving. it's not about them. π ββοΈ
see Section 2.9.4, Thread Scheduling for further details on thread scheduling attributes and their default settings. iykyk π
β RATIONALE β
if an implementation detects that the value specified by the attr argument to pthread_attr_getinheritsched() or pthread_attr_setinheritsched() does not refer to an initialized thread attributes object, it is recommended that the function should fail and report an [EINVAL] error. like, that's the recommended move. do with that what you will π
π¦ FUTURE DIRECTIONS π¦
None. β again, nothing. no plans. no drama. the future is quiet. π
π₯ SEE ALSO π₯
pthread_attr_destroy()pthread_attr_getscope()pthread_attr_getschedpolicy()pthread_attr_getschedparam()pthread_create()
and from 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.
and 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. yes bestie, the original is the referee, we're just the vibes. 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 . π
aaaand that's the whole page bestie!! you ate. π
β¨ this was IEEE/The Open Group, 2017, for PTHREAD...ITSCHED(3POSIX), and i am obsessed with you for reading all the way to the bottom. go set your scheduling attributes correctly, initialize your attr objects, and stay iconic ππ¦π
π¦ 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