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

71 lines
4.6 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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="Database record I/O and thread safety" />
<meta name="abstract" content="You can use the I/O feedback area of a database file to communicate results of I/O operations to the record I/O user. A typical application might have problems with thread safety because of the nature of the feedback area." />
<meta name="description" content="You can use the I/O feedback area of a database file to communicate results of I/O operations to the record I/O user. A typical application might have problems with thread safety because of the nature of the feedback area." />
<meta name="DC.Relation" scheme="URI" content="rzahwcomco.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahwdbcco.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="rzahwdio-dioco" />
<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>Database record I/O and thread safety</title>
</head>
<body id="rzahwdio-dioco"><a name="rzahwdio-dioco"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Database record I/O and thread safety</h1>
<div><p>You can use the I/O feedback area of a database file to communicate
results of I/O operations to the record I/O user. A typical application might
have problems with thread safety because of the nature of the feedback area.</p>
<div class="section"><p>When you perform an I/O operation, the support of the run time
and of the database ensures that the I/O operation is threadsafe. When the
I/O is complete, any locks that the run time holds are released
and control is given back to the application.</p>
</div>
<div class="section"><p>It is the application's responsibility to serialize access when
examining the I/O feedback area so that another thread does not use it simultaneously.
COBOL and RPG use the feedback area on every I/O operation, so if you do I/O
to the same shared file with different languages, you should serialize access
to the file even when you are not apparently using the feedback area.</p>
</div>
<div class="section"><p>For example, Thread 1 is using file A for record
I/O operations. The system stores information about those operations in the
feedback area for file A. After the I/O operation for Thread 1 completes,
Thread 1 manipulates the feedback area by examining fields in the feedback
area. If it does not protect the feedback area when Thread 2 uses file A for
record I/O operations, the system uses the same feedback area. Thread 1 may
get inconsistent results because Thread 2 is using the feedback area at the
same time. This occurs when sharing a file is conducted by the use of the
file pointer or file descriptor number. It is not a problem if the file is
opened in each thread.</p>
</div>
<div class="section"><p>You should use a synchronization technique to protect the feedback
area so that other application code or the system does not change it when
it is being accessed.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahwcomco.htm" title="Several programming errors often occur when writing multithreaded applications.">Common multithreaded programming errors</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="rzahwdbcco.htm" title="You should consider these items when using databases in multithreaded programs.">Database considerations for multithreaded programming</a></div>
</div>
</div>
</body>
</html>