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 this attr argument 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 the attr argument to pthread_attr_getinheritsched() or pthread_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 of inheritsched is 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> πŸ“š


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 πŸŽ€πŸ¦‹πŸ’–