Open System Services System Calls Reference Manual (G06.25+, H06.03+)
System Functions (n - p) pthread_create(2)
NAME
pthread_create - Creates a thread
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int pthread_create(
pthread_t *thread,
const pthread_attr_t *attr,
void * ( *start_routine ) ( void * ),
void *arg );
PARAMETERS
thread specifies the location to receive the identifier for the thread being created.
attr specifies the thread attributes object that defines the characteristics of the thread
being created. If you specify NULL or pthread_attr_default, then the default
attributes are:
SCHED_FIFO
The default scheduling policy for the schedpolicy attribute is
first-in, first-out.
PTHREAD_CREATE_JOINABLE
The default detachstate is joinable.
A thread is detached when created if the detachstate attribute of its thread object
is set to PTHREAD_CREATE_DETACHED.
start_routine specifies the function to be executed as the new thread’s start routine.
arg specifies the argument to the thread’s start routine.
DESCRIPTION
This function creates a thread, which is a single, sequential flow of control within a program. A
thread is the active execution of a designated routine, including any nested routine invocations.
Successful execution of this function causes the following actions:
• The system creates a thread object to describe and control the thread.
• The thread parameter receives an identifier for the new thread.
• An executable thread is created with attributes specified by the attr parameter (or with
default attributes if attr is NULL).
Thread Creation
The system creates a thread in the ready state and prepares the thread to begin executing its start
routine, which is the function passed to pthread_create() as the start_routine parameter.
Depending on the presence of other threads and their scheduling and priority attributes, the new
thread might start executing immediately. The new thread can also preempt its creator, depend-
ing on the two threads’ respective scheduling and priority attributes. The caller of
pthread_create() can synchronize with the new thread using either the pthread_join() function
or any mutually agreed upon mutexes or condition variables.
527186-003 Hewlett-Packard Company 5−55