PTHREAD...TACKSIZE(3POSIX)

✨ PROLOG ✨

okay bestie so first thing's first: this manual page is part of the POSIX Programmer's Manual. but like, heads up πŸ‘€ β€” the Linux implementation of this interface may differ (so pls go consult the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. no cap.


πŸŽ€ NAME πŸŽ€

pthread_attr_getstacksize, pthread_attr_setstacksize β€” get and set the stacksize attribute πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <pthread.h>

int pthread_attr_getstacksize(const pthread_attr_t *restrict attr,
    size_t *restrict stacksize);
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);

πŸ’– DESCRIPTION πŸ’–

so pthread_attr_getstacksize() and pthread_attr_setstacksize() do exactly what it says on the tin, bestie β€” they get and set the thread creation stacksize attribute inside the attr object. that's it, that's the vibe ✨

the stacksize attribute defines the minimum stack size (in bytes) allocated for the created thread's stack. like, the floor, not the ceiling, iykyk.

⚠️ okay important: the behavior is undefined if the value you pass as the attr argument to pthread_attr_getstacksize() or pthread_attr_setstacksize() doesn't refer to an initialized thread attributes object. don't do that. it's giving chaos 😭

πŸ‘‘ RETURN VALUE πŸ‘‘

when everything slays and completes successfully, both pthread_attr_getstacksize() and pthread_attr_setstacksize() return a value of 0 πŸ’š otherwise, an error number gets returned to tell you what went wrong.

and ooh, fun detail: pthread_attr_getstacksize() stores the stacksize attribute value in stacksize if it's successful. so that's where your answer lands 🫢


πŸ”₯ ERRORS πŸ”₯

pthread_attr_setstacksize() shall fail if:

  • EINVAL β€” the value of stacksize is less than {PTHREAD_STACK_MIN} or exceeds a system-imposed limit. like, too tiny or too extra, both get rejected πŸ’€

these functions shall not return an error code of [EINTR]. periodt.

the following sections are informative. (aka, the lore ✨)


🌸 EXAMPLES 🌸

None. πŸ’€ nothing to see here bestie.


🌈 APPLICATION USAGE 🌈

None. also nothing. iconic of them honestly.


🧚 RATIONALE 🧚

so if an implementation detects that the value specified by the attr argument to pthread_attr_getstacksize() or pthread_attr_setstacksize() does not refer to an initialized thread attributes object, it is recommended that the function should fail and report an [EINVAL] error. like, be polite about it, yk? πŸ™ˆ


⭐ FUTURE DIRECTIONS ⭐

None. the future is… nothing. lowkey peaceful ngl.


πŸ’œ SEE ALSO πŸ’œ

  • pthread_attr_destroy()
  • pthread_attr_getdetachstate()
  • pthread_create()

The Base Definitions volume of POSIX.1‐2017, <limits.h>, <pthread.h> 🌟


okay legal era, stay with me 🫢

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, dated 2017, and it lives at PTHREAD...TACKSIZE(3POSIX) β€” go forth and set your stack sizes responsibly, mwah πŸŽ€βœ¨