RTEMS Logo

RTEMS 4.7.1 On-Line Library


Thread Manager pthread_create - Create a Thread

PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

17.4.17: pthread_create - Create a Thread

CALLING SEQUENCE:

#include <pthread.h>

int pthread_create(
  pthread_t             *thread,
  const pthread_attr_t  *attr,
  void                 (*start_routine)( void *),
  void                  *arg
);

STATUS CODES:

EINVAL
The attribute set is not initialized.
EINVAL
The user specified a stack address and the size of the area was not large enough to meet this processor's minimum stack requirements.
EINVAL
The specified scheduler inheritance policy was invalid.
ENOTSUP
The specified contention scope was PTHREAD_SCOPE_PROCESS.
EINVAL
The specified thread priority was invalid.
EINVAL
The specified scheduling policy was invalid.
EINVAL
The scheduling policy was SCHED_SPORADIC and the specified replenishment period is less than the initial budget.
EINVAL
The scheduling policy was SCHED_SPORADIC and the specified low priority is invalid.
EAGAIN
The system lacked the necessary resources to create another thread, or the self imposed limit on the total number of threads in a process PTHREAD_THREAD_MAX would be exceeded.
EINVAL
Invalid argument passed.

DESCRIPTION:

The pthread_create routine is used to create a new thread with the attributes specified by attr. If the attr argument is NULL, then the default attribute set will be used. Modification of the contents of attr after this thread is created does not have an impact on this thread.

The thread begins execution at the address specified by start_routine with arg as its only argument. If start_routine returns, then it is functionally equivalent to the thread executing the pthread_exit service.

Upon successful completion, the ID of the created thread is returned in the thread argument.

NOTES:

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.

The signal mask of the newly created thread is inherited from its creator and the set of pending signals for this thread is empty.


PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

Copyright © 1988-2004 OAR Corporation