head	1.2;
access;
symbols
	Awe-2-10:1.2
	Awe-2-7:1.1;
locks
	grunwald:1.2; strict;
comment	@# @;


1.2
date	91.11.03.20.16.29;	author grunwald;	state Exp;
branches;
next	1.1;

1.1
date	91.10.02.05.31.07;	author grunwald;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Release 2.10
@
text
@From: Paul Maybee <paulm@@tigger.Colorado.EDU>
To: grunwald@@foobar.Colorado.EDU
Subject: Re:  solbourne shared memory
Date: Thu, 20 Sep 90 11:08:56 MDT
Status: RO

First, spinlock code:

===================================================================

/*
 * spinlock, unlock routines  - from OS/MP (Stuart Maybee)
 */
#include "asm_linkage.h"

/*
 * spinlock(lp)
 *      unsigned char   *lp;    { address of lock }
 *
 * routine to spin wait on the given lock until it is zero and then
 * atomically set it to nonzero.  The first loop avoids excessive
 * bus traffic when trying to acquire the lock because we don't do
 * a write until there is a chance to acquire the lock.
 *
 */
ENTRY(spinlock)
        ldub    [%o0],%g1
lock_loop:
        tst     %g1                     ! wait for lock to be zero
        bnz,a   lock_loop
        ldub    [%o0],%g1               ! reload lock in case we loop
        ldstub  [%o0],%g1               ! lock is zero, try to acquire it
        tst     %g1                     ! did we acquire lock?
        bnz,a   lock_loop               ! no, go back and try again
        ldub    [%o0],%g1               ! reload lock in case we didn't acquire        retl                            ! yes, return
        nop
EXIT(spinlock)

/*
 * unlock(lp)
 *      unsigned char   *lp;    { address of lock }
 *
 * clear a lock by atomically setting it to zero.
 *
 */
ENTRY(unlock)
        retl
        stb     %g0,[%o0]               ! set lock to zero
EXIT(unlock)

=======================================================================

the include file (asm_linkage.h) is in /usr/include/machine

About sharing memory, you are correct, you must write the memory to a file
first if you want to preserve it  -- seems like an obvious failing in mmap.

Let me know if I can be of further help.
-paul

@


1.1
log
@Works on Sequent, dec, sparc
@
text
@@
