PTHREAD_EQUAL(3POSIX)

๐Ÿ’– PTHREAD_EQUAL(3POSIX) ๐Ÿ’–

okay bestie, welcome to the POSIX Programmer's Manual โœจ this one's from the POSIX manual, and like โ€” heads up โ€” the Linux implementation of this interface may differ (so go peek at the corresponding Linux manual page for the tea on Linux behavior), or honestly the interface might not even be implemented on Linux at all. ๐Ÿ™ˆ


๐ŸŽ€ NAME ๐ŸŽ€

pthread_equal โ€” compare thread IDs. that's it. that's the whole job. slay.


โœจ SYNOPSIS โœจ

#include <pthread.h>

int pthread_equal(pthread_t t1, pthread_t t2);

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so this function shall compare the thread IDs t1 and t2. literally just vibes-checking whether two thread IDs are the same one. ๐Ÿ‘‘


๐Ÿ’… RETURN VALUE ๐Ÿ’…

  • pthread_equal() shall return a non-zero value if t1 and t2 are equal ๐Ÿซถ
  • otherwise, zero shall be returned.
๐Ÿšจ big yikes alert: if either t1 or t2 are not valid thread IDs, the behavior is undefined. no cap. undefined behavior is not the vibe, don't do it. ๐Ÿ’€

๐Ÿ˜ญ ERRORS ๐Ÿ˜ญ

no errors are defined. like, none. zero. nada. ๐ŸŒˆ

also, pthread_equal() shall not return an error code of [EINTR] โ€” so don't go looking for that one, bestie.

the following sections are informative (iykyk, that means they're the commentary, not the rules ๐Ÿ“).


๐Ÿฆ‹ EXAMPLES ๐Ÿฆ‹

None. ๐Ÿงš


๐Ÿ“ APPLICATION USAGE ๐Ÿ“

None. ๐Ÿ’œ


๐Ÿ‘‘ RATIONALE ๐Ÿ‘‘

okay so here's the why, and it's actually iconic:

implementations may choose to define a thread ID as a structure. and that's a flex, because it allows additional flexibility and robustness over using an int. for example, a thread ID could include a sequence number that allows detection of ``dangling IDs'' โ€” which is what you call copies of a thread ID that has been detached. ๐Ÿ•ต๏ธโ™€๏ธ

but here's the catch: since the C language does not support comparison on structure types, we can't just do t1 == t2 like some kind of casual. so the pthread_equal() function is provided to compare thread IDs. main character energy: they built a whole function because C said no. periodt. ๐Ÿ’…


๐Ÿ”ฎ FUTURE DIRECTIONS ๐Ÿ”ฎ

None. ๐ŸŒธ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • pthread_create()
  • pthread_self()
  • The Base Definitions volume of POSIX.1โ€2017, <pthread.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.

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 lil gem came to you courtesy of IEEE/The Open Group, dated 2017, and yeah โ€” it's PTHREAD_EQUAL(3POSIX) in the POSIX Programmer's Manual. go compare some thread IDs responsibly, mwah ๐Ÿ’–๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from