208 lines
6.3 KiB
HTML
208 lines
6.3 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>QlgSem_open_np()--Open Named Semaphore with Maximum Value (using
|
||
|
NLS-enabled path name)</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 -->
|
||
|
<!-- IPCSONU SCR A converted by B2H R4.1 (346) (CMS) by V2CDIJAB at -->
|
||
|
<!-- RCHVMW2 on 14 Sep 2000 at 17:12:58 -->
|
||
|
<!-- Edited by Kersten Feb 02 -->
|
||
|
<!-- This file has undergone html cleanup on 05/01/02 by JET -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!-- End Header Records -->
|
||
|
<!-- Java sync-link -->
|
||
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
||
|
</script>
|
||
|
|
||
|
<h2>QlgSem_open_np()--Open Named Semaphore with Maximum Value (using
|
||
|
NLS-enabled path name)</h2>
|
||
|
|
||
|
<div class="box" style="width: 80%;">
|
||
|
<br>
|
||
|
Syntax
|
||
|
|
||
|
<pre>
|
||
|
#include <semaphore.h>
|
||
|
#include <qlg.h>
|
||
|
|
||
|
sem_t * QlgSem_open_np(const Qlg_Path_Name_T *<em>name</em>, int <em>oflag</em>
|
||
|
mode_t <em>mode</em>, unsigned int <em>value</em>,
|
||
|
sem_attr_np_t * <em>attr</em>);
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
Service Program Name: QP0ZPSEM<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: Yes<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The <strong>QlgSem_open_np()</strong> function, like the <strong>
|
||
|
sem_open_np()</strong> function, opens a named semaphore and returns a
|
||
|
semaphore pointer that may be used on subsequent calls to <strong>
|
||
|
sem_post()</strong>, <strong>sem_post_np()</strong>, <strong>
|
||
|
sem_wait()</strong>, <strong>sem_wait_np()</strong>, <strong>
|
||
|
sem_trywait()</strong>, <strong>sem_getvalue()</strong>, and <strong>
|
||
|
sem_close()</strong>. The <strong>QlgSem_open_np()</strong> function takes a
|
||
|
pointer to a Qlg_Path_Name_T structure, while the <strong>
|
||
|
sem_open_np()</strong> function takes a pointer to a character string.</p>
|
||
|
|
||
|
<p>Limited information on the <em>name</em> parameter is provided in this API.
|
||
|
For additional information on the <em>name</em> parameter and a discussion of
|
||
|
other parameters, authorities required, return values, and related information,
|
||
|
see <a href="ipcsemon.htm">sem_open_np()</a>--Open Named Semaphore with Maximum
|
||
|
Value.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>name</strong></dt>
|
||
|
|
||
|
<dd>(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name
|
||
|
or a pointer to a path name of the semaphore to be opened. For more information
|
||
|
on the Qlg_Path_Name_T structure, see <a href="../apiref/pns.htm">Path name
|
||
|
format</a>.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Error Conditions</h3>
|
||
|
|
||
|
<p>If <strong>QlgSem_open_np()</strong> is not successful, <em>errno</em>
|
||
|
usually indicates the following error or one of the errors identified in <a
|
||
|
href="ipcsemon.htm#ecsemon">sem_open_np()</a>--Open Named Semaphore with
|
||
|
Maximum Value.</p>
|
||
|
|
||
|
<dl>
|
||
|
<dt><em>[ECONVERT]</em></dt>
|
||
|
|
||
|
<dd>A conversion error for the parameter <em>name</em>.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li>The <<strong>qlg.h</strong>> file (see <a href="unix13.htm">Header
|
||
|
Files for UNIX-Type Functions</a>)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="ipcsemon.htm">sem_open_np()</a>--Open Named Semaphore with Maximum
|
||
|
Value<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="ipcsemou.htm">QlgSem_open()</a>--Open Named Semaphore (using
|
||
|
NLS-enabled path name)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="ipcsemunu.htm">QlgSem_unlink()</a>--Unlink Named Semaphore (using
|
||
|
NLS-enabled path name)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
</ul>
|
||
|
|
||
|
<p><strong>Note:</strong> All of the related information for <strong>
|
||
|
sem_open_np()</strong> applies to <strong>QlgSem_open_np()</strong>. See
|
||
|
Related Information in <a href="ipcsemon.htm#risemon">sem_open()</a>.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Example</h3>
|
||
|
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
|
||
|
<p>The following example opens the named semaphore "/mysemaphore" and creates
|
||
|
the semaphore with an initial value of 10 and a maxiumum value of 11. The
|
||
|
permissions are set such that only the current user has access to the
|
||
|
semaphore.</p>
|
||
|
|
||
|
<pre>
|
||
|
#include <semaphore.h>
|
||
|
#include <qlg.h>
|
||
|
main() {
|
||
|
|
||
|
sem_t * my_semaphore;
|
||
|
int rc;
|
||
|
sem_attr_np_t attr;
|
||
|
|
||
|
#define mypath "/mysemaphore"
|
||
|
const char US_const[3]= "US";
|
||
|
const char Language_const[4]="ENU";
|
||
|
const char Path_Name_Del_const[2]= "/";
|
||
|
typedef struct pnstruct
|
||
|
{
|
||
|
Qlg_Path_Name_T qlg_struct;
|
||
|
char[100] pn; /* This size must be >= the path */
|
||
|
/* name length or be a pointer */
|
||
|
/* to the path name. */
|
||
|
|
||
|
};
|
||
|
struct pnstruct path;
|
||
|
|
||
|
|
||
|
/***************************************************************/
|
||
|
/* Initialize Qlg_Path_Name_T parameters */
|
||
|
/***************************************************************/
|
||
|
memset((void*)path name, 0x00, sizeof(struct pnstruct));
|
||
|
path.qlg_struct.CCSID = 37;
|
||
|
memcpy(path.qlg_struct.Country_ID,US_const,2);
|
||
|
memcpy(path.qlg_struct.Language_ID,Language_const,3);
|
||
|
path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
|
||
|
path.qlg_struct.Path_Length = sizeof(mypath)-1;
|
||
|
memcpy(path.qlg_struct.Path_Name_Delimiter,Path_Name_Del_const,1);
|
||
|
memcpy(path.pn,mypath,sizeof(mypath));
|
||
|
|
||
|
|
||
|
memset(&attr, 0, sizeof(attr));
|
||
|
attr.maxvalue=11;
|
||
|
my_semaphore = QlgSem_open_np((Qlg_Path_Name_T *)path name,
|
||
|
O_CREAT|O_EXCL,
|
||
|
S_IRUSR | S_IWUSR,
|
||
|
10,
|
||
|
&attr);
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
<hr>
|
||
|
API introduced: V5R1
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
||
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|