pthread_attr_setsuspendstate_np and pthread_attr_getsuspendstate_np Subroutine

Purpose

Controls whether a thread is created in a suspended state.

Library

Threads Library (libpthreads.a)

Syntax

#include <pthread.h>

int pthread_attr_setsuspendstate_np (attr, suspendstate)
pthread_attr_t *attr;
int suspendstate;

int pthread_attr_getsuspendstate_np (attr, suspendstate)
pthread_attr_t *attr;
int *suspendstate;

Description

The suspendstate attribute controls whether the thread is created in a suspended state. If the thread is created suspended, the thread start routine will not execute until pthread_continue_np is run on the thread. The pthread_attr_setsuspendstate_np and pthread_attr_getsuspendstate_np routines, respectively, set and get the suspendstate attribute in the attr object.

The suspendstate attribute can be set to either PTHREAD_CREATE_SUSPENDED_NP or PTHREAD_CREATE_UNSUSPENDED_NP. A value of PTHREAD_CREATE_SUSPENDED_NP causes all threads created with attr to be in the suspended state, whereas using a value of PTHREAD_CREATE_UNSUSPENDED_NP causes all threads created with attr to be in the unsuspended state. The default value of the suspendstate attribute is PTHREAD_CREATE_UNSUSPENDED_NP.

Parameters

Item Description
attr Specifies the thread attributes object.
suspendstate Points to where the suspendstate attribute value will be stored.

Return Values

Upon successful completion, pthread_attr_setsuspendstate_np and pthread_attr_getsuspendstate_np return a value of 0. Otherwise, an error number is returned to indicate the error.

The pthread_attr_getsuspendstate_np function stores the value of the suspendstate attribute in suspendstate if successful.

Error Codes

The pthread_attr_setsuspendstate_np function will fail if:

Item Description
EINVAL The value of suspendstate is not valid.