PTHREAD...GETSCOPE(3POSIX)
π PTHREAD_ATTR_GETSCOPE, PTHREAD_ATTR_SETSCOPE β the POSIX girlies π
okay so bestie, welcome to the PTHREAD...GETSCOPE(3POSIX) page, straight outta the POSIX Programmer's Manual. it's giving realtime threads, it's giving attribute objects, it's giving contentionscope β¨
πΈ PROLOG πΈ
so like, this manual page is part of the POSIX Programmer's Manual. but lowkey a heads up: the Linux implementation of this interface may differ β so consult the corresponding Linux manual page for the deets on Linux behavior. or honestly? the interface might not even be implemented on Linux at all. π iykyk.
β¨ NAME β¨
pthread_attr_getscope, pthread_attr_setscope β get and set the contentionscope attribute π
(REALTIME THREADS, no cap π«Ά)
π SYNOPSIS π
#include <pthread.h>
int pthread_attr_getscope(const pthread_attr_t *restrict attr,
int *restrict contentionscope);
int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
π¦ DESCRIPTION π¦
so pthread_attr_getscope() and pthread_attr_setscope() respectively shall get and set the contentionscope attribute inside the attr object. that's it, that's the job. π
the contentionscope attribute may have these values:
PTHREAD_SCOPE_SYSTEMβ signifying system scheduling contention scopePTHREAD_SCOPE_PROCESSβ signifying process scheduling contention scope
both of those symbols are defined in the <pthread.h> header, periodt.
β οΈ okay important: the behavior is undefined if the value specified by theattrargument topthread_attr_getscope()orpthread_attr_setscope()does not refer to an initialized thread attributes object. so likeβ¦ initialize ur attrs, bestie. don't be that girl. π
π RETURN VALUE π
if it slays (i.e. successful), pthread_attr_getscope() and pthread_attr_setscope() shall return zero. otherwise an error number shall be returned to indicate the error. no in-between. π«Ά
π ERRORS π
pthread_attr_setscope() β shall fail if:
ENOTSUPβ an attempt was made to set the attribute to an unsupported value. not on this system's watch π
pthread_attr_setscope() β may fail if:
EINVALβ the value ofcontentionscopeis not valid.
and also, huge: these functions shall not return an error code of [EINTR]. nope. never. don't even ask. β¨
the following sections are informative. (casual. low stakes. we're just chatting.)
π EXAMPLES π
None.
like literally none. nothing. empty. the void. π³οΈ
π§ APPLICATION USAGE π§
so once these attributes have been set, a thread can be created with the specified attributes using pthread_create(). cute, right? π
and listen β using these routines does not affect the current running thread. so don't expect ur own vibe to shift. π
see Section 2.9.4, Thread Scheduling for further details on thread scheduling attributes and their default settings. it's giving required reading, fr fr. π
π RATIONALE π
if an implementation detects that the value specified by the attr argument to pthread_attr_getscope() or pthread_attr_setscope() 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 polite thing to do. π
β FUTURE DIRECTIONS β
None.
(the future? empty. iconic behavior honestly. β¨)
π SEE ALSO π
pthread_attr_destroy()pthread_attr_getinheritsched()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. π
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 . π
okay bye bestie, this was IEEE/The Open Group, 2017 β PTHREAD...GETSCOPE(3POSIX), signing off πβ¨π
π¦ 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