1<!--$Id: env_set_shm_key.so,v 10.28 2004/09/28 15:04:20 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DB_ENV->set_shm_key</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DB_ENV->set_shm_key</b> 14</td> 15<td align=right> 16<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a> 17<a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db.h> 23<p> 24int 25DB_ENV->set_shm_key(DB_ENV *dbenv, long shm_key); 26<p> 27int 28DB_ENV->get_shm_key(DB_ENV *dbenv, long *shm_keyp); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DB_ENV->set_shm_key</b> 32<p>Specify a base segment ID for Berkeley DB environment shared memory regions 33created in system memory on VxWorks or systems supporting X/Open-style 34shared memory interfaces; for example, UNIX systems supporting 35<b>shmget</b>(2) and related System V IPC interfaces.</p> 36<p>This base segment ID will be used when Berkeley DB shared memory regions are 37first created. It will be incremented a small integer value each time 38a new shared memory region is created; that is, if the base ID is 35, 39the first shared memory region created will have a segment ID of 35, 40and the next one will have a segment ID between 36 and 40 or so. A 41Berkeley DB environment always creates a master shared memory region; an 42additional shared memory region for each of the subsystems supported by 43the environment (Locking, Logging, Memory Pool and Transaction); plus 44an additional shared memory region for each additional memory pool cache 45that is supported. Already existing regions with the same segment IDs 46will be removed. See <a href="/ref/env/region.html">Shared Memory 47Regions</a> for more information.</p> 48<p>The intent behind this method is two-fold: without it, applications 49have no way to ensure that two Berkeley DB applications don't attempt to use 50the same segment IDs when creating different Berkeley DB environments. In 51addition, by using the same segment IDs each time the environment is 52created, previously created segments will be removed, and the set of 53segments on the system will not grow without bound.</p> 54<p>The database environment's base segment ID may also be configured using the 55environment's <a href="/ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file. The syntax of the entry in that 56file is a single line with the string "set_shm_key", one or more whitespace 57characters, and the ID. 58Because the <a href="/ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file is read when the database environment 59is opened, it will silently overrule configuration done before that 60time.</p> 61<p>The DB_ENV->set_shm_key method configures operations performed using the specified 62<a href="/api_c/env_class.html">DB_ENV</a> handle, not all operations performed on the underlying 63database environment.</p> 64<p>The DB_ENV->set_shm_key method may not be called after the <a href="/api_c/env_open.html">DB_ENV->open</a> method is 65called. 66If the database environment already exists when 67<a href="/api_c/env_open.html">DB_ENV->open</a> is called, the information specified to DB_ENV->set_shm_key 68must be consistent with the existing environment or corruption can 69occur.</p> 70<p>The DB_ENV->set_shm_key method 71returns a non-zero error value on failure 72and 0 on success. 73</p> 74<b>Parameters</b> <br> 75 <b>shm_key</b><ul compact><li>The <b>shm_key</b> parameter is the base segment ID for the database 76environment.</ul> 77<br> 78<br><b>Errors</b> 79<p>The DB_ENV->set_shm_key method 80may fail and return one of the following non-zero errors:</p> 81<br> 82<b>EINVAL</b><ul compact><li>If the method was called after <a href="/api_c/env_open.html">DB_ENV->open</a> was called; or if an 83invalid flag value or parameter was specified.</ul> 84<br> 85<hr size=1 noshade> 86<b>Description: DB_ENV->get_shm_key</b> 87<p>The DB_ENV->get_shm_key method returns the base segment ID.</p> 88<p>The DB_ENV->get_shm_key method may be called at any time during the life of the 89application.</p> 90<p>The DB_ENV->get_shm_key method 91returns a non-zero error value on failure 92and 0 on success. 93</p> 94<b>Parameters</b> <br> 95 <b>shm_keyp</b><ul compact><li>The DB_ENV->get_shm_key method returns the 96base segment ID in <b>shm_keyp</b>.</ul> 97<br> 98<hr size=1 noshade> 99<br><b>Class</b> 100<a href="/api_c/env_class.html">DB_ENV</a> 101<br><b>See Also</b> 102<a href="/api_c/env_list.html">Database Environments and Related Methods</a> 103</tt> 104<table width="100%"><tr><td><br></td><td align=right> 105<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a> 106</td></tr></table> 107<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 108</body> 109</html> 110