Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Apr 1998 06:55:41 -0700
From:      John-Mark Gurney <gurney_j@efn.org>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        FreeBSD Current <freebsd-current@FreeBSD.ORG>
Subject:   Re: kernel support for memory semaphores/locks...
Message-ID:  <19980408065541.03335@hydrogen.nike.efn.org>
In-Reply-To: <2165.891967475@critter.freebsd.dk>; from Poul-Henning Kamp on Tue, Apr 07, 1998 at 06:44:35PM %2B0200
References:  <19980407072623.51939@hydrogen.nike.efn.org> <2165.891967475@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
Poul-Henning Kamp scribbled this message on Apr 7:
> >so, how do we go about locking on a shared memory areas?
> >
> >after discussing this with a friend, ther HAS to be a lock based on a
> >shared memory location...  the problem with storing the SYSV semaphore
> >semid is that there isn't an atomic way of obtaining the new semid
> >and putting it in a shared location after a machine reboot...
> 
> Make your own lock with the cmp8xchg instruction, just like the kernel 
> does.  Check the "lock" instruction on the i386.  Also check out the

actually, I used the xchg instruction which is even on the 386 and all
xchg instructions already assert lock, so it isn't necessary...

> "mplock.[schwhatever]" somewhere in the kernel.
> 
> >using assembly to do atomic locking isn't an option as you would have
> >to spin on the lock...
> 
> No, you'd go to sleep for a jiffy and check again...  I belive a yield()
> syscall is in the pipeline or maybe already in.

thanks, I've done it this way... and leached most of the source from
sys/i386/i386/simplelock.s...  also, I decided to back port the yield
syscall (note, we now have sched_yield and yield syscalls) to 2.2.1-R
and it works great...

as a side effect, I found out that my k6/225 can do about 111k context
switch + syscalls/sec...

now to start testing my mmalloc library now that I have locking in...

-- 
  John-Mark Gurney                      Modem Rev/FAX: +1 541 346 9237
  Cu Networking					  P.O. Box 5693, 97405

  Live in Peace, destroy Micro$oft, support free software, run FreeBSD
	    Don't trust anyone you don't have the source for

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980408065541.03335>