/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*
* @(#)lock.h 10.17 (Sleepycat) 1/3/99
*/
#ifndef DB_LOCK_DEFAULT_N
#endif
/*
* The locker id space is divided between the transaction manager and the lock
* manager. Lockid's start at 0 and go to DB_LOCK_MAXID. Txn Id's start at
* DB_LOCK_MAXID + 1 and go up to TXN_INVALID.
*/
/* Check for region catastrophic shutdown. */
return (DB_RUNRECOVERY); \
}
/*
* The lock region consists of:
* The DB_LOCKREGION structure (sizeof(DB_LOCKREGION)).
* The conflict matrix of nmodes * nmodes bytes (nmodes * nmodes).
* The hash table for object lookup (hashsize * sizeof(DB_OBJ *)).
* The locks themselves (maxlocks * sizeof(struct __db_lock).
* The objects being locked (maxlocks * sizeof(DB_OBJ)).
* String space to represent the DBTs that are the objects being locked.
*/
struct __db_lockregion {
};
/*
* Since we will be keeping DBTs in shared memory, we need the equivalent
* of a DBT that will work in shared memory.
*/
typedef struct __sh_dbt {
} SH_DBT;
struct __db_lockobj {
union {
} wlinks;
union {
} dlinks;
/* Allocate room in the object to
* hold typical DB lock structures
* so that we do not have to
* allocate them from shalloc. */
};
/*
* The lock table is the per-process cookie returned from a lock_open call.
*/
struct __db_locktab {
};
/* Test for conflicts. */
/*
* Resources in the lock region. Used to indicate which resource
* is running low when we need to grow the region.
*/
typedef enum {
struct __db_lock {
/*
* Wait on mutex to wait on lock. You reference your own mutex with
* ID 0 and others reference your mutex with ID 1.
*/
};
/*
* This is a serious layering violation. To support nested transactions, we
* need to be able to tell that a lock is held by a transaction (as opposed to
* some other locker) and to be able to traverse the parent/descendent chain.
* In order to do this, each lock held by a transaction maintains a reference
* to the shared memory transaction structure so it can be accessed during lock
* promotion. As the structure is in shared memory, we cannot store a pointer
* to it, so we use the offset within the region. As nothing lives at region
* offset 0, we use that to indicate that there is no transaction associated
* with the current lock.
*/
/*
* We cannot return pointers to the user (else we cannot easily grow regions),
* so we return offsets in the region. These must be converted to and from
* regular pointers. Always use the macros below.
*/
/*
* The lock header contains the region structure and the conflict matrix.
* Aligned to a large boundary because we don't know what the underlying
* type of the hash table elements are.
*/
#define LOCK_HEADER_SIZE(M) \
/*
* For the full region, we need to add the locks, the objects, the hash table
* and the string space (which is 16 bytes per lock).
*/
#define LOCK_REGION_SIZE(M, N, H) \
(ALIGN(LOCK_HEADER_SIZE(M) + \
(H) * sizeof(DB_HASHTAB), MUTEX_ALIGNMENT) + \
#include "lock_ext.h"