ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahw_5.4.0.1/rzahwjobco.htm

86 lines
5.3 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Use separate jobs to run functions that are not threadsafe" />
<meta name="abstract" content="There are several threadsafe mechanisms to submit a new job to complete the processing you need." />
<meta name="description" content="There are several threadsafe mechanisms to submit a new job to complete the processing you need." />
<meta name="DC.Relation" scheme="URI" content="rzahwnonco.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzahwjob-jobco" />
<meta name="DC.Language" content="en-us" />
<!-- 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. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Use separate jobs to run functions that are not threadsafe</title>
</head>
<body id="rzahwjob-jobco"><a name="rzahwjob-jobco"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use separate jobs to run functions that are not threadsafe</h1>
<div><p>There are several threadsafe mechanisms to submit a new job to
complete the processing you need. </p>
<div class="section"><ul><li>If your application uses CL commands that are not threadsafe, you can
use the system API <span class="apiname">Qp0zSystem()</span>. This API is similar to
the C system() function; however, it starts a new process before running the
CL command. It also returns some information about the results of the CL command
that you ran. For more details about <span class="apiname">Qp0zSystem()</span>, see
the System API Programming Reference. </li>
<li>If your application calls APIs or programs that are not thread safe, you
might use the <span class="apiname">spawn()</span> API to start a new job. If you use
the <span class="apiname">spawn()</span> API, your application must decide which part
of the application environment gets duplicated into the child. The <span class="apiname">spawn()</span> API
allows the child process to inherit open IFS files, sockets, or other resources
from the parent. For details about <span class="apiname">spawn()</span>, see the System
API Programming Reference.</li>
<li>Your application might frequently use multiple functions that are not
thread safe. In this case, you should use one of the previously mentioned
mechanisms to start a new job. That new job can function as a server, running
the code that is not threadsafe when requested by your application. Your application
can use message queues, data queues, or perhaps semaphores to communicate
with your server. </li>
</ul>
</div>
<div class="section"><div class="p">When using any of these separate job mechanisms,
you need to be aware of the following problems involved with using a different
job to complete some of your application processing:<ul><li>Input/output considerations:<p>The server job cannot perform normal I/O
without conflicting with the application I/O processing. The application I/O
processing can affect file offsets or locks that are maintained on system
objects. Attempts at I/O can conflict between the jobs. </p>
</li>
<li>Parameter passing:<p>Passing pointers or other types of
complex parameters to the functions that are not threadsafe might not be easy
to accomplish. That function runs in a separate job. You need to solve the
problems involved with passing complex data to that function. </p>
</li>
<li>Returning function calls:<p>The results from the function that is not
threadsafe might be more complex than the simple pass/fail type of information
that is provided by some of the mechanisms described above. This is similar
to the parameter passing issue described above. </p>
</li>
<li>Job attributes:<p>You might have additional complexity to manage when
trying to duplicate your application's environment in the server job. For
example, if you started your application as user ALICE, and you started the
server job as user BOB, the application behavior is not correct. </p>
</li>
</ul>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahwnonco.htm" title="Your multithreaded application at times requires access to functions or system services that are not thread safe. There are few completely safe alternatives for calling these functions.">Function calls that are not thread safe</a></div>
</div>
</div>
</body>
</html>