Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

thrd_exit(3C)

Name

thrd_create, thrd_current, thrd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, thrd_yield - C11 thread functions

Synopsis

#include <threads.h>
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);
thrd_t thrd_current(void);
int thrd_detach(thrd_t thr);
int thrd_equal(thrd_t thr0, thrd_t thr1);
_Noreturn void thrd_exit(int res);
int thrd_join(thrd_t thr, int *res);
int thrd_sleep(const struct timespec *duration,
          struct timespec *remaining);
void thrd_yield(void);

Description

The thrd_create(), thrd_current(), thrd_detach(), thrd_equal(), thrd_exit(), thrd_join(), thrd_sleep(), and thrd_yield() functions are part of the threads interfaces as specified in the C11 standard. With the exception of thrd_sleep() and thrd_yield() functions, they are simple wrappers over the more general pthreads functions. See INCITS/ISO/IEC 9899:2011.

C11 Threads
POSIX Threads
thrd_create()
pthread_create()
thrd_current()
pthread_self()
thrd_detach()
pthread_detach()
thrd_equal()
pthread_equal()
thrd_exit()
pthread_exit()
thrd_join()
pthread_join()

Return Values

Upon successful completion, the thrd_create(), thrd_detach(), and thrd_join() functions return thrd_success. If memory allocation fails for the requested thread, thrd_create() returns thrd_nomem. Otherwise, thrd_create(), thrd_detach(), and thrd_join() return thrd_error to indicate the error.

The thrd_current() function returns the thread identifier of the calling thread.

The thrd_equal() function returns a non-zero value if thr0 and thr1 refer to the same thread. Otherwise, 0 is returned.

If the thrd_sleep() function returns because the requested time has elapsed, it's return value is 0. Otherwise if thrd_sleep() has been interrupted by a signal or fails, −1 is returned.

No value is returned by either the thrd_exit() function or the thrd_yield() function.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe

See Also

yield(2), nanosleep(3C), pthread_create(3C), pthread_detach(3C), pthread_equal(3C), pthread_exit(3C), pthread_join(3C), pthread_self(3C), threads.h(3HEAD), attributes(7)