PTHREAD_A...ERITSCHED(3P)
π PTHREAD_A...ERITSCHED(3P) π
okay bestie, sit down, hydrate, because we're reading a whole page out of the POSIX Programmer's Manual (that's the 3P energy right there) about pthread_attr_getinheritsched and pthread_attr_setinheritsched. yes the title is literally abbreviated like that. no I will not be explaining why. β¨
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual, fr fr.
The Linux implementation of this interface may differ β so go check the corresponding Linux manual page for the deets on Linux behavior β or, plot twist, the interface might just not be implemented on Linux at all. π
π NAME π
pthread_attr_getinheritsched, pthread_attr_setinheritsched β get and set the inheritsched attribute (REALTIME THREADS). yes we're in our realtime era. π
β¨ 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 way this works: pthread_attr_getinheritsched() and pthread_attr_setinheritsched() shall, respectively, get and set the inheritsched attribute in the attr argument. one gets, one sets, they're a duo. iconic.
When these attributes objects get used by pthread_create(), the inheritsched attribute is the main character that decides how the other scheduling attributes of the created thread shall be set. it's giving puppet master. π§
The supported values of inheritsched shall be:
PTHREAD_INHERIT_SCHEDβ says the thread scheduling attributes shall be inherited from the creating thread, and the scheduling attributes in thisattrargument shall be ignored. like, respectfully, your attr settings do not exist here. πPTHREAD_EXPLICIT_SCHEDβ says the thread scheduling attributes shall be set to the corresponding values from this attributes object. your settings, your rules. periodt.
The symbols PTHREAD_INHERIT_SCHED and PTHREAD_EXPLICIT_SCHED are defined in the <pthread.h> header. π«Ά
The following thread scheduling attributes defined by POSIX.1β2008 are affected by the inheritsched attribute:
- scheduling policy (
schedpolicy) - scheduling parameters (
schedparam) - scheduling contention scope (
contentionscope)
β οΈ behavior check, 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 behavior is not a vibe. do not do this. π
β RETURN VALUE β
If successful, both pthread_attr_getinheritsched() and pthread_attr_setinheritsched() shall return zero. otherwise, an error number shall be returned to indicate the error. that's it, that's the whole return story. π
π₯ ERRORS π₯
The pthread_attr_setinheritsched() function shall fail if:
ENOTSUPβ an attempt was made to set the attribute to an unsupported value. like, we don't do that here. π
The pthread_attr_setinheritsched() function may fail if:
EINVALβ the value ofinheritschedis not valid.
Also, these functions shall not return an error code of [EINTR]. nope, not a thing. π
The following sections are informative.
π¦ EXAMPLES π¦
None.
literally none. the void. the silence. moving on. π
π APPLICATION USAGE π
After these attributes have been set, a thread can be created with the specified attributes using pthread_create(). so like, set your little attr situation, then birth the thread. π«Ά
Using these routines does not affect the current running thread. you're just editing the blueprint, not renovating the building. no cap.
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. that's the recommended move. it's giving "please just error out politely". β¨
π FUTURE DIRECTIONS π
None.
the future? empty. we love a stable API. π
π SEE ALSO π
pthread_attr_destroy()pthread_attr_getscope()pthread_attr_getschedpolicy()pthread_attr_getschedparam()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. π so if something looks off, the original is the one holding the whistle.
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 to you from IEEE/The Open Group, dated 2017, and it's PTHREAD_A...ERITSCHED(3P) from the POSIX Programmer's Manual. go set some scheduling attributes responsibly. mwah πβ¨π
π¦ 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