head	1.3;
access;
symbols
	release_4_2:1.3
	aix_ok:1.3
	Version_2_1:1.2;
locks; strict;
comment	@ * @;


1.3
date	91.06.10.20.57.28;	author kemnitz;	state Exp;
branches;
next	1.2;

1.2
date	91.01.25.22.11.48;	author hong;	state Exp;
branches;
next	1.1;

1.1
date	91.01.18.21.40.49;	author hong;	state Exp;
branches;
next	;


desc
@for spin locks for new buffer manager
@


1.3
log
@generalization of spinlocks.
@
text
@/*
 * spin.h -- synchronization routines
 *
 * Identification:
 *	$Header: RCS/spin.h,v 1.2 91/01/25 22:11:48 hong Exp Locker: kemnitz $
 */

#ifndef	SPINIncluded	/* Include this file only once */
#define SPINIncluded	1

/* 
 * two implementations of spin locks
 *
 * sequent, sparc, sun3: real spin locks. uses a TAS instruction; see
 * src/storage/ipc/s_lock.c for details.
 *
 * default: fake spin locks using semaphores.  see spin.c
 *
 */

typedef int SPINLOCK;

#define is_LOCKED(lock)		Assert(SpinIsLocked(lock))

#endif	/* !defined(SPINIncluded) */
@


1.2
log
@cleaned up spinlock code
@
text
@d5 1
a5 1
 *	$Header: RCS/spin.h,v 1.1 91/01/18 21:40:49 hong Exp Locker: hong $
d14 2
a15 1
 * sequent: real spin locks. uses a TAS instruction.
@


1.1
log
@Initial revision
@
text
@d5 1
a5 1
 *	$Header:  $
d12 1
a12 1
 * Three (or more) possible implementations of spinlocks.
d14 1
a14 3
 * SPIN_DBG: running as single user so we can fake the
 * 	spin locks with a normal integer.  Any blocking
 *	causes an error.
a15 2
 * SPIN_OK: real spin locks. requires a TAS instruction.
 *
a19 3

#ifdef SPIN_DBG

d22 1
a22 4
#define is_LOCKED(a) Assert((a->tas)==1)
#define SpinAcquire(spinlock) Assert(! (*spinlock));(*spinlock)= 1;
#define SpinRelease(spinlock) Assert(*spinlock); (*spinlock) = 0;
#define SpinCreate(spinlock) (*spinlock)=1;
a23 26

#else 
struct spinlock {
  int tas;
};

#ifdef SPIN_OK

typedef struct spinlock SPINLOCK;

#define is_LOCKED(a) Assert((a->tas)==1)
#define SpinAcquire(spinlock) while( ! TAS(*spinlock) );
#define SpinRelease(spinlock) (*spinlock) = 0;
#define SpinCreate(spinlock) SpinAcquire(spinlock);

#else

#define is_LOCKED(a) Assert(SpinIsLocked(a))
typedef struct spinlock SPINLOCK;

#endif
#endif

/* spin.c */
InitSpinLocks();
SPINLOCK *SpinAlloc();
@
