File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / sys / h / iidr.h.2.0
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:29:42 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/*
**	Copyright (c) 1983 Relational Technology Inc.
**
**	IIDR.H	- structures for the INGRES lock driver
**
**	Description:
**		Defines the constants and the structures used by the lock device.
*/
#ifdef	vax
#undef	BYTE_SWAP
#undef	NOTVAX
#else
#define	BYTE_SWAP
#define	NOTVAX
#endif

/*	The request codes to the lock device.		*/

# define	KN_R_LOCK	1
# define	KN_R_UNLOCK	2
# define	KN_R_CONVERT	3
# define	KN_R_RELEASE	4
# define	KN_R_UNIQ	5
# define	KN_R_STAT	6

/*	The lock modes that the device supports		 */

# define	KN_M_NL		0
# define	KN_M_CR		1
# define	KN_M_CW		2
# define	KN_M_PR		3
# define	KN_M_PW		4
# define	KN_M_EX		5

/*	Possible extra return values from the lock device	*/

# define	EDEADLOCK	-1
# define	ECHILDREN	-2
# define	ELOCKID		-3
# define	ENOTQUEUED	-4
# define	ERESOURCE	-5
# define	EBUG		-6

/*	The structure used by the user to pass lock key information to the lock device.	*/

typedef struct
{
	short	lk_parent;			/*	parentid when setting a lock	*/
	short	lk_type;			/*	the type of lock		*/
	long	lk_key;				/*	the key when setting a lock	*/
}	LOCK_KEY;

/*	Collect performance numbers about the lock device in this structure.	*/

typedef struct
{
	long	ii_locks;		/*	number of lock requests			*/
	long	ii_unlocks;		/*	number of unlocks requests		*/
	long	ii_converts;		/*	number of conversion requests		*/
	long	ii_lockwaits;		/*	number of lock requests that waited	*/
	long	ii_waitconverts;	/*	number of convert requests that waited	*/
	long	ii_deadconverts;	/*	number of conversion deadlocks		*/
	long	ii_deadsearchs;		/*	number of deadlock searches performed	*/
	long	ii_deadlocks;		/*	number of resource deadlocks found	*/
}	STAT;

/*
	The format of a request code to the lock device.

	BYTE_SWAP must be defined for processors such as
		the 3B5 and 68K where the byte order is
		the opposite of the vax.
*/

typedef struct
{
#	ifndef	BYTE_SWAP
	unsigned	cmd_opcode:3;		/* function code	*/
	unsigned	cmd_lock_mode:3;	/* lock mode		*/
	unsigned	cmd_no_queue:1;		/* don't wait modifier	*/
#	else
	unsigned	cmd_pad:25;		/* count on bit order	*/
	unsigned	cmd_no_queue:1;		/* don't wait modifier	*/
	unsigned	cmd_lock_mode:3;	/* lock mode		*/
	unsigned	cmd_opcode:3;		/* function code	*/
#	endif
}	CMD;

typedef struct _QUEUE	QUEUE;

struct	_QUEUE
{
	QUEUE	*q_next;
	QUEUE	*q_prev;
};

QUEUE	*remque();
QUEUE	*insque();

typedef struct _LKB LKB;
typedef struct _RSB RSB;

/*
**	A Resource Block.
**		An RSB is allocated for each unique key that is locked.
**		It contains information about that states of locks queued against this resource.
*/

struct _RSB
{
	QUEUE		rsb_next;			/*	next of hash chain					*/
	QUEUE		rsb_wait_lkb;			/*	queue of waiting locks					*/
	QUEUE		rsb_grant_lkb;			/*	queue of granted locks followed by conversion requests	*/
	RSB		*rsb_parent;			/*	parent resource						*/
	LKB		*rsb_deadlock_next;		/*	used to save next on recursion in deadlock tree		*/
	LKB		*rsb_deadlock_curr;		/*	used to save curr on recursion in deadlock tree		*/
	int		rsb_pad;			/*	for future use						*/
	union
	{
		LOCK_KEY	rsb_lk;			/*	used to save lock from user	*/
		struct
		{
			unsigned char	rsb_xgrant_mode;	/*	granted mode of locked		*/
			unsigned char	rsb_xconvert_mode;	/*	effective convert mode 		*/
			short		rsb_xtype;		/*	first part of the key		*/
			long		rsb_xrkey;		/*	second part of the key		*/
		}		rsb_actual;
	}		rsb_key;
};

# define	rsb_grant_mode		rsb_key.rsb_actual.rsb_xgrant_mode
# define	rsb_convert_mode	rsb_key.rsb_actual.rsb_xconvert_mode
# define	rsb_depth		rsb_key.rsb_actual.rsb_xdepth
# define	rsb_type		rsb_key.rsb_actual.rsb_xtype
# define	rsb_rkey		rsb_key.rsb_actual.rsb_xrkey

/*
**	The User structure.
**		Contains information about processes that currently have the lock device open.
**		Used to store information that can't be put in the 'u' struct.
*/

typedef struct
{
	short		usr_pid;			/*	something to identify this process	*/
	char		usr_state;			/*	miscellaneous status info		*/
	char		usr_visited;			/*	noded visited marke for deadlock search	*/
	LKB		*usr_wait;			/*	lock that we are waiting on		*/
}	USR;

# define	USR_NULLSTATE	00
# define	USR_WAIT	01
# define	USR_VISITED	01
# define	USR_NOTVISITED	00

/*
**	The Lock Block.
**		Contains information about a given processes lock request against a resource.
*/

struct	_LKB
{
	QUEUE		lkb_next;			/*	next LBK of the same type	*/
	LKB		*lkb_parent;			/*	parent lock block		*/
	RSB		*lkb_rsb;			/*	associated resource block	*/
	USR		*lkb_usr;			/*	owning process			*/
	unsigned char	lkb_grant_mode;			/*	granted mode			*/
	unsigned char	lkb_request_mode;		/*	requested lock mode		*/
	unsigned char	lkb_state;			/*	current lock state		*/
	unsigned char	lkb_children;			/*	number of child locks		*/
};

# define	LKB_FREE	0
# define	LKB_GRANT	1
# define	LKB_CONVERT	2
# define	LKB_WAIT	3

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.