#include <pthread.h> int pthread_getpthreadoption_np(pthread_option_np_t *optionData);Service Program Name: QP0WTCBH
The pthread_getpthreadoption_np() function gets option data from the pthread run-time for the process.
Input and output data is specified and returned uniquely based on the specified optionData. See the table below for details about input and output. The option field in the optionData parameter is always required. Other fields may be input, output, or ignored, based on the specific option used.
For all options, every reserved field in the structure represented by optionData must be binary zero or the EINVAL error is returned. Unless otherwise noted for an option, the target field in the option parameter is always ignored.
The currently supported options, the data they represent, and the valid operations are as follows:
option field of the option parameter | Description |
---|---|
PTHREAD_OPTION_POOL_NP | When a thread terminates and it is detached or joined to, certain data structures from the pthreads run-time are maintained in a pool for possible reuse by future threads. This improves performance for creating threads. Typically, an application should not be concerned with this storage pool. Use this option to determine what the current maximum size of the allowed storage pool is. The optionValue field of the optionData parameter is set to the current maximum number of thread structures, which is maintained in the storage pool. By default, the maximum size of the storage reuse pool contains enough room for 512 thread structures. |
PTHREAD_OPTION_POOL_CURRENT_NP | When a thread terminates and it is detached or joined to, certain data structures from the pthreads run-time are maintained in a pool for possible reuse by future threads. This improves performance for creating threads. Typically, an application should not be concerned with this storage pool. Use this option to determine how many thread structures are currently in the storage pool. The optionValue field of the optionData parameter is set to the current number of thread structures, which are contained in the storage pool. By default, the storage pool contains no thread structures. When a thread terminates and is detached or joined to and the current size of the pool is less than the maximum size, the thread structure is added to the pool. |
PTHREAD_OPTION_THREAD_CAPABLE_NP | Not all i5/OS jobs can start threads at all times. Use this option to determine whether thread creation is currently allowed for your process. The optionValue field of the optionData parameter is set to indicate whether thread creation is currently allowed. The field is set to 0 to indicate that thread creation is not allowed, the field will be set to 1 to indicate thread creation is allowed. If thread creation is not allowed, pthread_create() fails with the EBUSY error. See pthread_create() for more details. |
None.
If pthread_getpthreadoption_np() was not successful, the error condition returned usually indicates one of the following errors. Under some conditions, the value returned could indicate an error other than those listed here.
The value specified for the argument is not correct.
See Code disclaimer information for information pertaining to code examples.
#define _MULTI_THREADED #include <pthread.h> #include <stdio.h> #include "check.h" void *threadfunc(void *parm) { printf("Inside the thread\n"); return NULL; } void showCurrentSizeOfPool(void) { int rc; pthread_option_np_t opt; memset(&opt, 0, sizeof(opt)); opt.option = PTHREAD_OPTION_POOL_CURRENT_NP; rc = pthread_getpthreadoption_np(&opt); checkResults("pthread_getpthreadoption_np()\n", rc); printf("Current number of thread structures in pool is %d\n", opt.optionValue); return; } int main(int argc, char **argv) { pthread_t thread; int rc=0; pthread_option_np_t opt; printf("Enter Testcase - %s\n", argv[0]); printf("Create thread using the NULL attributes\n"); rc = pthread_create(&thread, NULL, threadfunc, NULL); checkResults("pthread_create(NULL)\n", rc); memset(&opt, 0, sizeof(opt)); opt.option = PTHREAD_OPTION_POOL_NP; rc = pthread_getpthreadoption_np(&opt); checkResults("pthread_getpthreadoption_np()\n", rc); printf("Current maximum pool size is %d thread structures\n", opt.optionValue); showCurrentSizeOfPool(); printf("Joining to the thread may it to the storage pool\n"); rc = pthread_join(thread, NULL); checkResults("pthread_join()\n", rc); showCurrentSizeOfPool(); printf("Main completed\n"); return 0; }
Output:
Enter Testcase - QP0WTEST/TPGEtopT Create thread using the NULL attributes Current maximum pool size is 512 thread structures Current number of thread structures in pool is 0 Joining to the thread may it to the storage pool Inside the thread Current number of thread structures in pool is 1 Main completed
Top | Pthread APIs | APIs by category |