pthread_getpthreadoption_np()--Get Pthread Run-Time Option Data


  Syntax:
 #include <pthread.h>
 int pthread_getpthreadoption_np(pthread_option_np_t *optionData);  
  Service Program Name: QP0WTCBH

  Default Public Authority: *USE

  Threadsafe: Yes

  Signal Safe: Yes

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:



Authorities and Locks

None.


Parameters

option
(Input/Output) Address of the variable containing option information and to contain output option information.

Return Value

0
pthread_getpthreadoption_np() was successful.

value
pthread_getpthreadoption_np() was not successful. value is set to indicate the error condition.

Error Conditions

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.

[EINVAL]

The value specified for the argument is not correct.


Related Information


Example

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#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



API introduced: V4R3

[ Back to top | Pthread APIs | APIs by category ]