head	1.10;
access;
symbols
	release_4_2:1.10
	aix_ok:1.10;
locks; strict;
comment	@ * @;


1.10
date	92.05.28.20.29.10;	author mer;	state Exp;
branches;
next	1.9;

1.9
date	92.04.13.19.12.40;	author mer;	state Exp;
branches;
next	1.8;

1.8
date	91.11.14.19.38.28;	author kemnitz;	state Exp;
branches;
next	1.7;

1.7
date	91.08.29.23.49.37;	author mer;	state Exp;
branches;
next	1.6;

1.6
date	91.08.26.18.05.52;	author mer;	state Exp;
branches;
next	1.5;

1.5
date	91.08.12.15.17.36;	author mer;	state Exp;
branches;
next	1.4;

1.4
date	91.07.29.07.10.36;	author mer;	state Exp;
branches;
next	1.3;

1.3
date	91.07.23.19.54.54;	author mer;	state Exp;
branches;
next	1.2;

1.2
date	91.07.23.10.43.40;	author mer;	state Exp;
branches;
next	1.1;

1.1
date	91.07.22.15.15.09;	author mer;	state Exp;
branches;
next	;


desc
@new file for new lock manager
@


1.10
log
@TransactionIdData type no longer exists (WARNING xids now 4 bytes!!!)
@
text
@/*
 * proc.h 
 * 
 * $Header: /private/mer/pg.latest/src/lib/H/storage/RCS/proc.h,v 1.9 1992/04/13 19:12:40 mer Exp mer $
 */

#ifndef _PROC_H_
#define _PROC_H_

#include "storage/ipci.h"
#include "storage/lock.h"
#include <sys/sem.h>


typedef struct {
  int	 		sleeplock;
  int			semNum;
  IpcSemaphoreId	semId;
  IpcSemaphoreKey	semKey;
} SEMA;

/*
 * Each backend has:
 */
typedef struct proc {

  /* proc->links MUST BE THE FIRST ELEMENT OF STRUCT (see ProcWakeup()) */

  SHM_QUEUE         links;	/* proc can be waiting for one event(lock) */
  SEMA              sem;	/* ONE semaphore to sleep on */
  int               errType; 	/* error code tells why we woke up */

  int               procId;  	/* unique number for this structure
			 	 * NOT unique per backend, these things
				 * are reused after the backend dies.
				 */

  int               critSects;	/* If critSects > 0, we are in sensitive
				 * routines that cannot be recovered when
				 * the process fails.
				 */

  int               prio;	/* priority for sleep queue */

  TransactionId     xid;	/* transaction currently being executed
				 * by this proc
				 */

  LOCK *            waitLock;	/* Lock we're sleeping on */
  int               token;	/* info for proc wakeup routines */	
  int		    pid;	/* This procs process id */
  short		    sLocks[MAX_SPINS];	/* Spin lock stats */
  SHM_QUEUE	    lockQueue;	/* locks associated with current transaction */
} PROC;

/*
 * Global variables for this module.
 *	This is only used for garbage collection.
 */
typedef struct procglobal {
  SHMEM_OFFSET	freeProcs;
  int		numProcs;
  IPCKey	currKey;
} PROC_HDR;

extern PROC *MyProc;

#define PROC_INCR_SLOCK(lock) if (MyProc) (MyProc->sLocks[(lock)])++
#define PROC_DECR_SLOCK(lock) if (MyProc) (MyProc->sLocks[(lock)])--

/*
 * flags explaining why process woke up
 */
#define NO_ERROR 	0
#define ERR_TIMEOUT	1
#define ERR_BUFFER_IO	2

#define MAX_PRIO	50
#define MIN_PRIO	(-1)

/*
 * Function Prototypes
 */
PROC_QUEUE *ProcQueueAlloc ARGS((char *name));
void ProcQueueInit ARGS((PROC_QUEUE *queue));
void InitProcess ARGS((IPCKey key));
void ProcReleaseLocks();
void ProcAddLock ARGS((SHM_QUEUE *elem));
void ProcReleaseSpins ARGS((PROC *proc));
PROC *ProcWakeup ARGS((PROC *proc, int errType));
bool ProcSemaphoreKill ARGS((int pid));
bool ProcKill ARGS((int exitStatus, int pid));
int ProcGetId();
int ProcLockWakeup ARGS((PROC_QUEUE *queue, char * ltable, char * lock));
int HandleDeadLock();
int ProcSleep ARGS((
	PROC_QUEUE *queue, 
	SPINLOCK spinlock, 
	int token, 
	int prio, 
	LOCK *lock
));


#endif _PROC_H_
@


1.9
log
@multi-user fixes relating to shm hash tables and queues
@
text
@d4 1
a4 1
 * $Header: /u/mer/pg/src/lib/H/storage/RCS/proc.h,v 1.8 1991/11/14 19:38:28 kemnitz Exp mer $
d45 1
a45 1
  TransactionIdData xid;	/* transaction currently being executed
@


1.8
log
@protos checkin.
@
text
@d4 1
a4 1
 * $Header: RCS/proc.h,v 1.7 91/08/29 23:49:37 mer Exp Locker: kemnitz $
a87 1
void ProcWakeup ARGS((PROC *proc, int errType));
d90 1
@


1.7
log
@purge old lmgr code
@
text
@d4 1
a4 1
 * $Header: /users/mer/postgres/src/lib/H/storage/RCS/proc.h,v 1.6 1991/08/26 18:05:52 mer Exp mer $
d94 1
a94 1
int ProcLockWakeup ARGS((PROC_QUEUE *queue, Address ltable, Address lock));
@


1.6
log
@changes to support parallel backends
@
text
@d4 1
a4 1
 * $Header: RCS/proc.h,v 1.5 91/08/12 15:17:36 mer Exp Locker: mer $
d81 23
a103 1
PROC_QUEUE *ProcQueueAlloc();
@


1.5
log
@multi-user junk
@
text
@d4 1
a4 1
 * $Header: /users/mer/postgres/src/lib/H/storage/RCS/proc.h,v 1.4 91/07/29 07:10:36 mer Exp Locker: mer $
d51 1
a51 1
  int		    backendId;	/* This procs backend id */
@


1.4
log
@split header file to break up include dependence with lock.h
@
text
@d4 1
a4 1
 * $Header: /users/mer/postgres/src/lib/H/storage/RCS/proc.h,v 1.3 91/07/23 19:54:54 mer Exp Locker: mer $
d51 3
a53 1
  SHM_QUEUE	lockQueue;	/* locks associated with current transaction */
d65 5
@


1.3
log
@move in structs from proc.c
@
text
@d4 1
a4 1
 * $Header: /users/mer/postgres/src/lib/H/storage/RCS/proc.h,v 1.2 91/07/23 10:43:40 mer Exp Locker: mer $
a9 1
#include "storage/shmem.h"
a13 4
typedef struct procQueue {
  SHM_QUEUE	links;
  int		size;
} PROC_QUEUE;
a14 1

d49 1
@


1.2
log
@so as not include it twice.
@
text
@d4 1
a4 1
 * $Header$
d7 2
a8 2
#ifndef _PROC_H
#define _PROC_H
d12 1
d20 8
d29 41
a78 2
extern int ProcCurrTxId;

d81 1
a81 11
/* for txtime.c and txlog.c */
#define MAX_PROCS	100


typedef struct {
  int	 		sleeplock;
  int			semNum;
  IpcSemaphoreId	semId;
  IpcSemaphoreKey	semKey;
} SEMA;
#endif _PROC_H
@


1.1
log
@Initial revision
@
text
@d3 2
d7 3
d43 1
@
