pthread_attr_setsuspendstate_np()

Updated: April 19, 2023

Set the thread suspend state attribute

Synopsis:

#include <pthread.h>

int pthread_attr_setsuspendstate_np(
                 pthread_attr_t* attr,
                 int suspend );

Arguments:

attr
A pointer to the pthread_attr_t structure that defines the attributes to use when creating new threads. For more information, see pthread_attr_init().
suspend
The new value for the thread suspend state; one of the following:
  • PTHREAD_CREATE_NOT_SUSPENDED — when the thread is created, it isn't put into a suspended state.
  • PTHREAD_CREATE_SUSPENDED — when the thread is created, it's put into a suspended state.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The pthread_attr_setsuspendstate_np() function sets the thread suspend state attribute in the thread attribute object attr to suspend. The default value for the thread suspend state is PTHREAD_CREATE_NOT_SUSPENDED.

You can use pthread_attr_getsuspendstate_np() to get the suspend state attribute.

The “np” in these functions' names stands for “non-POSIX.”

Starting a thread in a suspended state is the equivalent of creating a thread and immediately calling ThreadCtlExt(), specifying the thread ID and the _NTO_TCTL_ONE_THREAD_HOLD command. You can unsuspend the thread with the _NTO_TCTL_ONE_THREAD_CONT command.

Returns:

EOK
Success.
EINVAL
Invalid thread suspend state value.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes