The API documentation includes example programs for each API. The header file shown below is used for all of 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 that is contained in the examples 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 that is provided should not be considered complete 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 error checking to be used for production code and should not be used directly for that purpose.
Be sure to see Writing and compiling threaded programs and Running threaded programs 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. Alternatively, you can use CRTBNDC to compile and link the program in one step.
When you run the example programs, you must be aware of a requirement:
The job that runs a threaded program must be specially initialized by the system to support threads. Currently, several mechanisms allow you to start a job that is capable of creating multiple kernel threads.
See Running threaded programs for detailed information on these methods.
See Code disclaimer information for information pertaining to code examples.
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
Top | Pthread APIs | APIs by category |