United States-English |
|
|
HP-UX Reference > Ppthread_create(3T)Pthread LibraryHP-UX 11i Version 3: February 2007 |
|
NAMEpthread_create() — create a new thread of execution. SYNOPSIS#include <pthread.h> int pthread_create( pthread_t *__restrict thread, const pthread_attr_t *__restrict attr, void *(*start_routine)(void *), void *__restrict arg ); PARAMETERS
DESCRIPTIONThe pthread_create() function is used to create a new independent thread within the calling process. The thread will be created according to the attributes specified by attr. If attr is NULL, the default attributes will be used. The values of the attributes in attr describe the characteristics of the to-be-created thread in detail. Refer to the function pthread_attr_init() for a list of the default attribute values. A single attributes object can be used in multiple calls to the function pthread_create(). When a thread is created with an attributes object, the attributes are, in effect, copied into the created thread. Consequently, any change to the attributes object will not affect any previously created threads. Once all threads needing a specific attributes object have been created, the attributes object is no longer needed and may be destroyed. When the new thread is created, it will execute start_routine(), which has only one parameter, arg. If start_routine() returns, an implicit call to pthread_exit() is made. The return value of start_routine() is used as the thread's exit status. The created thread's scheduling policy and priority, contention scope, detach state, stack size, and stack address are initialized according to their respective attributes in attr. The thread's signal mask is inherited from the creating thread. The thread's set of pending signals is cleared. Refer to pthread_exit(3T), pthread_detach(3T), and pthread_join(3T) for more information on thread termination and synchronizing with terminated threads. On success, the ID of the created thread is returned in thread. If pthread_create() fails, a thread is not created and the contents of thread are undefined. Thread IDs are guaranteed to be unique only within a process. NOTE: If the main thread returns from main(), an implicit call to exit() is made. The return value of main() is used as the process' exit status. The main thread can terminate without causing the process to terminate by calling pthread_exit(). RETURN VALUEUpon successful completion, pthread_create() returns zero. Otherwise, an error number is returned to indicate the error (the errno variable is not set). ERRORSIf any of the following occur, the pthread_create() function returns the corresponding error number:
|
Printable version | ||
|