X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/ed554bc5e4201344d7eaad78263566e79428759c..fd88f5c5678c80ff5e338adc372d28a52ad20530:/usr/src/sys/news3400/include/param.h diff --git a/usr/src/sys/news3400/include/param.h b/usr/src/sys/news3400/include/param.h index cf08d90d25..75dee5cfac 100644 --- a/usr/src/sys/news3400/include/param.h +++ b/usr/src/sys/news3400/include/param.h @@ -37,13 +37,14 @@ * * from: Utah $Hdr: machparam.h 1.11 89/08/14$ * - * @(#)param.h 8.1 (Berkeley) 6/11/93 + * @(#)param.h 8.3 (Berkeley) 5/14/95 */ /* * Machine dependent constants for DEC Station 3100. */ #define MACHINE "news3400" +#define NCPUS 1 #define COFF /* @@ -121,9 +122,9 @@ #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ - ((unsigned)(bytes) >> DEV_BSHIFT) + ((bytes) >> DEV_BSHIFT) #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ - ((unsigned)(db) << DEV_BSHIFT) + ((db) << DEV_BSHIFT) /* * Map a ``block device block'' to a file system block. @@ -212,3 +213,62 @@ extern char *intrnames[]; #define INTR_RENDER 44 #define NINTRSLOT 45 /* # of intrcnt[] slot */ + +#ifndef _SIMPLELOCK_H_ +#define _SIMPLELOCK_H_ +/* + * A simple spin lock. + * + * This structure only sets one bit of data, but is sized based on the + * minimum word size that can be operated on by the hardware test-and-set + * instruction. It is only needed for multiprocessors, as uniprocessors + * will always run to completion or a sleep. It is an error to hold one + * of these locks while a process is sleeping. + */ +struct simplelock { + int lock_data; +}; + +#if !defined(DEBUG) && NCPUS > 1 +/* + * The simple-lock routines are the primitives out of which the lock + * package is built. The machine-dependent code must implement an + * atomic test_and_set operation that indivisibly sets the simple lock + * to non-zero and returns its old value. It also assumes that the + * setting of the lock to zero below is indivisible. Simple locks may + * only be used for exclusive locks. + */ +static __inline void +simple_lock_init(lkp) + struct simplelock *lkp; +{ + + lkp->lock_data = 0; +} + +static __inline void +simple_lock(lkp) + __volatile struct simplelock *lkp; +{ + + while (test_and_set(&lkp->lock_data)) + continue; +} + +static __inline int +simple_lock_try(lkp) + __volatile struct simplelock *lkp; +{ + + return (!test_and_set(&lkp->lock_data)) +} + +static __inline void +simple_unlock(lkp) + __volatile struct simplelock *lkp; +{ + + lkp->lock_data = 0; +} +#endif /* NCPUS > 1 */ +#endif /* !_SIMPLELOCK_H_ */