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 species the location to receive the identier for the thread being created.
attr species the thread attributes object that denes 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
rst-in, rst-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 species the function to be executed as the new threads start routine.
arg species the argument to the threads start routine.
DESCRIPTION
This function creates a thread, which is a single, sequential ow 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 identier for the new thread.
An executable thread is created with attributes specied 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 threadsrespective 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 555