From owner-freebsd-current Tue Apr 7 18:38:02 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA13114 for freebsd-current-outgoing; Tue, 7 Apr 1998 18:38:02 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from sendero.simon-shapiro.org (sendero-fddi.Simon-Shapiro.ORG [206.190.148.2]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id SAA13083 for ; Tue, 7 Apr 1998 18:37:55 -0700 (PDT) (envelope-from shimon@simon-shapiro.org) Received: (qmail 6005 invoked from network); 8 Apr 1998 01:47:19 -0000 Received: from localhost.simon-shapiro.org (HELO sendero-fxp0.simon-shapiro.org) (@127.0.0.1) by localhost.simon-shapiro.org with SMTP; 8 Apr 1998 01:47:19 -0000 Message-ID: X-Mailer: XFMail 1.3-alpha-032998 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <19980407072623.51939@hydrogen.nike.efn.org> Date: Tue, 07 Apr 1998 18:47:19 -0700 (PDT) Reply-To: shimon@simon-shapiro.org Organization: The Simon Shapiro Foundation From: Simon Shapiro To: John-Mark Gurney Subject: RE: kernel support for memory semaphores/locks... Cc: FreeBSD Current Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 07-Apr-98 John-Mark Gurney wrote: > I have writen a memory block based dynamic allocation system (mmalloc).. > I was planning on using a lock to prevent multiple processes from > accessing the allocation strutures... but the only real way is using > SYSV semaphores... Not true. Try the DLM driver. Faster, cleaner, and distributed (well, remote host is almost done). You can lock anything you want in ways more sophisticated than semaphores can. > 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... > > so, there are a couple ways we can do this... > a) create a new type of file descriptor that is opened on a memory > range... there are a couple of features with this... you could > use the poll mechanism to obtain a lock on that region, or you > could use read/write to this memory location... this could be > useful for allowing another process to read/write into your data > area... > b) create two new sysctl's that do locking/unlocking on a region > of memory... this is a simpler method but less powerful... > > using assembly to do atomic locking isn't an option as you would have > to spin on the lock... > > or is there already a way to do locks using the kernel already? > > -- > 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 ---------- Sincerely Yours, Simon Shapiro Shimon@Simon-Shapiro.ORG Voice: 503.799.2313 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message