From owner-freebsd-current Wed Apr 8 06:57:38 1998 Return-Path: <owner-freebsd-current@FreeBSD.ORG> Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA05437 for freebsd-current-outgoing; Wed, 8 Apr 1998 06:57:38 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from d183-205.uoregon.edu (d183-205.uoregon.edu [128.223.183.205]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA05432 for <freebsd-current@FreeBSD.ORG>; Wed, 8 Apr 1998 06:57:36 -0700 (PDT) (envelope-from gurney_j@efn.org) Received: (from jmg@localhost) by d183-205.uoregon.edu (8.8.7/8.8.7) id GAA02490; Wed, 8 Apr 1998 06:55:42 -0700 (PDT) Message-ID: <19980408065541.03335@hydrogen.nike.efn.org> 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... References: <19980407072623.51939@hydrogen.nike.efn.org> <2165.891967475@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.69 In-Reply-To: <2165.891967475@critter.freebsd.dk>; from Poul-Henning Kamp on Tue, Apr 07, 1998 at 06:44:35PM +0200 Reply-To: John-Mark Gurney <gurney_j@resnet.uoregon.edu> Organization: Cu Networking X-Operating-System: FreeBSD 2.2.1-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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