88 lines
3.2 KiB
HTML
88 lines
3.2 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>Writing and compiling threaded programs</title>
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- Change History: -->
|
||
|
<!-- YYMMDD USERID Change description -->
|
||
|
<!-- NETMG2 SCRIPT A converted by B2H R4.1 (346) (CMS) by HOLTJM at -->
|
||
|
<!-- RCHVMW2 on 29 Jan 1999 at 10:01:37 -->
|
||
|
<!--File Edited November 2001 -->
|
||
|
<!--End Header Records -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!-- Java sync-link -->
|
||
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
||
|
</script>
|
||
|
|
||
|
<h2>Writing and compiling threaded programs</h2>
|
||
|
|
||
|
<p>When writing and compiling code that use threads or that run in a threaded
|
||
|
job, make sure to do the following:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>Ensure that all of the APIs or system services that you use are threadsafe.
|
||
|
See <a href="../rzahw/rzahwovepo.htm">Multithreaded applications</a> for an
|
||
|
introduction to threads and general information about i5/OS threads.<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>Insert the following lines into any module that uses the thread data types
|
||
|
or definitions.
|
||
|
|
||
|
<pre>
|
||
|
#define _MULTI_THREADED
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
#include <pthread.h>
|
||
|
</pre>
|
||
|
|
||
|
<p>The preprocessor definition <strong>_MULTI_THREADED</strong> must come
|
||
|
before the <strong>pthread.h</strong>.</p>
|
||
|
|
||
|
<p>See <a href="rzah4hed.htm">Header files for Pthread functions</a> for more
|
||
|
information on header files.</p>
|
||
|
|
||
|
<p>See <a href="rzah4mpv.htm">Using the _MULTI_THREADED preprocessor
|
||
|
definition</a> for more information on the _MULTI_THREADED preprocessor
|
||
|
definition.</p>
|
||
|
</li>
|
||
|
|
||
|
<li>Compile the program normally; use the <strong>CRTCMOD</strong> followed by
|
||
|
the <strong>CRTPGM</strong> or <strong>CRTSRVPGM</strong> commands. You can
|
||
|
also use the <strong>CRTBNDC</strong> CL command to create your threaded
|
||
|
program.<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>Since Pthread APIs can operate on functions and data which could exist in
|
||
|
different compilation units (modules), the same storage model and data model
|
||
|
must be used throughout all compilation units within a program or service
|
||
|
program that uses Pthread APIs. Otherwise, unpredictable behavior and failures
|
||
|
will occur. Refer to the information on teraspace and single-level store in the
|
||
|
<a href="../bookssc415606.pdf" target="_blank">ILE Concepts</a><img src="wbpdf.gif" alt="Link to PDF">
|
||
|
book for more information on storage model and data model.</li>
|
||
|
</ul>
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center">
|
||
|
<a href="rzah4mst.htm">Pthread APIs</a> |
|
||
|
<a href="aplist.htm">APIs by category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|