[Prev] [Contents] [Next]

Pthread API Descriptions

Information about the example programs

The API documentation and concepts document includes example programs for all APIs. The following header file is used for all the examples. It should be named check.h (member CHECK in file H in a library in the library list).

In most cases error checking is contained in the examples that causes the program to exit() if any failure is detected. In some cases, error checking is left out of the examples for brevity. In general, the error checking provided should not be considered robust enough for all applications. All return codes from any system functions should be validated and appropriate action should be taken when failures occur.

The examples are provided "as-is" for demonstration and education purposes only. They do not necessarily provide or implement an appropriate level of robustness to be used for production code and should not be used directly for that purpose.

Be sure to see "Writing and compiling threaded programs" on page 18 and "Running threaded programs" on page 19 for more information about compiling and running the example programs.

To create the examples, make sure the member CHECK is created in a file H in your library list. Use CRTCMOD on the name that you download the member to, then use CRTPGM to link the module into a program object. Alternately, you can use CRTBNDC to compile and link the program in one step.

When you run the example programs, there are a few requirements that you must be aware of. The job that runs a threaded program must be specially initialized by the system to support threads. Currently, you can start a job that is capable of creating multiple kernel threads using the spawn() API. The spawn() API has a new flag in the spawn inheritance structure that allows you to turn on the multi-thread capability for the child job. In future releases as more of the system is made thread safe, this requirement will be removed.

The QUSRTOOL library also provides source code and an example CL command to allow you to create and use a SPAWN CL command in a fashion that is similar to the SMBJOB CL command. See "SPAWN CL command, QUSRTOOL example" on page 52 for more information.

File Check.h used by API examples programs

This example header file must be in the library list when you compile the example programs.

#ifndef _CHECK_H
#define _CHECK_H
/* headers used by a majority of the example program */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

/* Simple function to check the return code and exit the program
   if the function call failed
   */
static void checkResults(char *string, int rc) {
  if (rc) {
    printf("Error on : %s, rc=%d",
           string, rc);
    exit(EXIT_FAILURE);
  }
  return;
}

#endif



[Prev] [Contents] [Next]
Copyright © 1998, IBM Corporation. All rights reserved.
Comments? Contact
rchthrds@us.ibm.com