RTEMS Logo

RTEMS 4.7.0 On-Line Library


Thread Manager pthread_exit - Terminate the Current Thread

PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

17.4.18: pthread_exit - Terminate the Current Thread

CALLING SEQUENCE:

#include <pthread.h>

void pthread_exit(
  void *status
);

STATUS CODES:

NONE

DESCRIPTION:

The pthread_exit routine is used to terminate the calling thread. The status is made available to any successful join with the terminating thread.

When a thread returns from its start routine, it results in an implicit call to the pthread_exit routine with the return value of the function serving as the argument to pthread_exit.

NOTES:

Any cancellation cleanup handlers that hace been pushed and not yet popped shall be popped in reverse of the order that they were pushed. After all cancellation cleanup handlers have been executed, if the thread has any thread-specific data, destructors for that data will be invoked.

Thread termination does not release or free any application visible resources including byt not limited to mutexes, file descriptors, allocated memory, etc.. Similarly, exitting a thread does not result in any process-oriented cleanup activity.

There is no concept of a single main thread in RTEMS as there is in a tradition UNIX system. POSIX requires that the implicit return of the main thread results in the same effects as if there were a call to exit. This does not occur in RTEMS.

All access to any automatic variables allocated by the threads is lost when the thread exits. Thus references (i.e. pointers) to local variables of a thread should not be used in a global manner without care. As a specific example, a pointer to a local variable should NOT be used as the return value.


PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

Copyright © 1988-2004 OAR Corporation