From ingvar at cathouse.bofh.se Fri Jun 4 15:57:21 2004 From: ingvar at cathouse.bofh.se (Ingvar) Date: Fri, 04 Jun 2004 16:57:21 +0100 Subject: [Small-cl-src-discuss] Web page revamp (and possible default-license-change) Message-ID: Now that Actual Round Tuits seem to have arrived, so I have done some changes taht I think are in line with what we discussed before. The following text should now appear on the "small-cl-src" information page: ----------------------------------- This mailing list is intended for "small" Common Lisp sources. For now, "small" is defined as single-file, less than 64 KB, in plain text. Unless other is specified, anything posted to the list from 2004-07-01 is presumed to be "copyright owner, use as you want, keep the copyright notice on relevant code" unless explicitly noted otherwise. Anything posted prior to this date can be presumed to be "ask poster, do no assume a license". ------------------------------------ If people are unhappy with that, I am willing to change it. I think it's more-or-less in line with what was opreviously discussed. //Ingvar From wence at gmx.li Fri Jun 11 20:22:29 2004 From: wence at gmx.li (Lawrence Mitchell) Date: Fri, 11 Jun 2004 21:22:29 +0100 Subject: [Small-cl-src-discuss] Eye-candy for gnus users. Message-ID: For those of you who use Gnus, this little snippet of elisp, which can sit in your ~/.gnus makes postings to small-cl-src, should they match the regexp "^;;;" font-locked as lisp-mode buffers. Yes, yes, it's not CL, I claim something or other... (add-to-list 'mailcap-mime-extensions '(".lisp" . "application/lisp")) (add-to-list 'mm-automatic-display "application/lisp") (add-to-list 'mm-inlined-types "application/lisp") (add-to-list 'mm-inline-media-tests '("application/lisp" my-display-lisp-inline identity)) (add-to-list 'mm-uu-type-alist '(small-cl-src "^;;;" nil my-mm-small-cl-src-extract nil my-mm-small-cl-src-test)) (eval-after-load "mm-uu" '(mm-uu-configure)) (defun my-mm-small-cl-src-test () (and gnus-newsgroup-name ;; replace this with whatever your small-cl-src's ;; `gnus-newsgroup-name' is. (string-equal gnus-newsgroup-name "gmane.lisp.sources.code"))) (defun my-mm-small-cl-src-extract () (mm-make-handle (mm-uu-copy-to-buffer start-point end-point) '("application/lisp") nil nil (list mm-dissect-disposition (cons 'filename "Lisp source file")))) (defun my-display-lisp-inline (handle) (mm-display-inline-fontify handle 'lisp-mode)) -- Lawrence Mitchell From randall at randallsquared.com Sun Jun 27 03:46:08 2004 From: randall at randallsquared.com (Randall Randall) Date: Sat, 26 Jun 2004 23:46:08 -0400 Subject: [Small-cl-src-discuss] simple locking Message-ID: <860B53EA-C7EC-11D8-B6C3-000A95A0F1E8@randallsquared.com> This is intended to be a simple locking protocol for systems that need to be usable on both serve-event-only systems, like CMUCL on PPC, and more ordinary multi-processing systems. I'm currently using it as part of PSILISP, my webapp framework. This seems to work, and people I've run it by agree that it seems to work, but there could be some serious problem with it, so use at your own risk. I am only an egg. (defmacro enqueue (queue) "Appends a unique ID to a queue." (let ((id (gensym))) `(let ((,id (gensym))) (setf ,queue (append ,queue (list ,id))) ,id))) (defmacro lock (queue) "Waits in turn in the activity queue until all previous members have exited." (let ((id (gensym))) `(let* ((,id (enqueue ,queue))) #+(and acl-compat (not allegro) (not cmu)) ; CMUCL on PPC doesn't have MP, so we have to use serve-event (ACL-COMPAT.MP:process-wait "waiting for lock" #'eq ,id (car ,queue)) #+allegro (MP:process-wait "waiting for lock" #'eq ,id (car ,queue)) #+cmu (do () ((eq ,id (car ,queue))) (sys:serve-event 0)) ,id))) (defmacro unlock (queue) `(pop ,queue)) Use example, which assumes a WIDGET structure or class, with a MYWIDGET instance, and a WIDGET-LOCK accessor. (defmacro with-locked-widget ((lock-id-var queue) &body body) "Provides a method of locking a widget while in use, if everyone uses this." `(let ((,lock-id-var (lock ,queue))) (unwind-protect (progn , at body) (unlock ,queue)))) (with-locked-widget (l-id (widget-lock mywidget)) ; do stuff ) -- Randall Randall Property law should use #'EQ , not #'EQUAL . From randall at randallsquared.com Sun Jun 27 04:01:52 2004 From: randall at randallsquared.com (Randall Randall) Date: Sun, 27 Jun 2004 00:01:52 -0400 Subject: [Small-cl-src-discuss] simple locking In-Reply-To: <860B53EA-C7EC-11D8-B6C3-000A95A0F1E8@randallsquared.com> References: <860B53EA-C7EC-11D8-B6C3-000A95A0F1E8@randallsquared.com> Message-ID: On Jun 26, 2004, at 11:46 PM, Randall Randall wrote: And, of course, I sent to the wrong one. My apologies. -- Randall Randall Property law should use #'EQ , not #'EQUAL . From randall at randallsquared.com Sun Jun 27 18:36:06 2004 From: randall at randallsquared.com (Randall Randall) Date: Sun, 27 Jun 2004 14:36:06 -0400 Subject: [Small-cl-src-discuss] Re: [Small-cl-src] Re: simple locking retry In-Reply-To: References: <3C24F439-C7EF-11D8-8912-000A95A0F1E8@randallsquared.com> Message-ID: On Jun 27, 2004, at 8:58 AM, Joe Marshall wrote: > Randall Randall writes: > >> Second try; let's see if I get it right this time: >> >> This is intended to be a simple locking protocol for >> systems that need to be usable on both serve-event-only >> systems, like CMUCL on PPC, and more ordinary >> multi-processing systems. I'm currently using it as >> part of PSILISP, my webapp framework. >> >> This seems to work, and people I've run it by agree >> that it seems to work, but there could be some serious >> problem with it, so use at your own risk. I am only >> an egg. >> >> This code is released as public domain. >> >> (defmacro enqueue (queue) >> "Appends a unique ID to a queue." >> (let ((id (gensym))) >> `(let ((,id (gensym))) >> (setf ,queue (append ,queue (list ,id))) >> ,id))) > > This isn't thread safe. If two processes attempted to enter the queue > simultaneously, one could get lost. Because the second could run between evaluation of ,queue and evaluation of APPEND? Okay. Is there an atomic way to do that append such that it is thread safe without using specialized machinery not available with serve-event? Alternatively, I guess I could use more #+ expressions. -- Randall Randall Property law should use #'EQ , not #'EQUAL . From froydnj at cs.rice.edu Sun Jun 27 20:44:10 2004 From: froydnj at cs.rice.edu (Nathan Froyd) Date: Sun, 27 Jun 2004 15:44:10 -0500 Subject: [Small-cl-src-discuss] Re: [Small-cl-src] Re: simple locking retry In-Reply-To: References: <3C24F439-C7EF-11D8-8912-000A95A0F1E8@randallsquared.com> Message-ID: <20040627204410.GA13046@blunux.cs.rice.edu> On Sun, Jun 27, 2004 at 02:36:06PM -0400, Randall Randall wrote: > On Jun 27, 2004, at 8:58 AM, Joe Marshall wrote: > >This isn't thread safe. If two processes attempted to enter the queue > >simultaneously, one could get lost. > > Because the second could run between evaluation of > ,queue and evaluation of APPEND? Okay. Is there > an atomic way to do that append such that it is > thread safe without using specialized machinery not > available with serve-event? CMUCL under x86 supports several "set place atomically" primitives that use the processor's cmpxchg instruction to provide true atomicity. (apropos "ATOMIC-") to have a peek at what's there. Since you're on PPC, this may not help that much... -- Nathan | From Man's effeminate slackness it begins. --Paradise Lost From randall at randallsquared.com Sun Jun 27 21:17:37 2004 From: randall at randallsquared.com (Randall Randall) Date: Sun, 27 Jun 2004 17:17:37 -0400 Subject: [Small-cl-src-discuss] simple locking retry In-Reply-To: <20040627204410.GA13046@blunux.cs.rice.edu> References: <3C24F439-C7EF-11D8-8912-000A95A0F1E8@randallsquared.com> <20040627204410.GA13046@blunux.cs.rice.edu> Message-ID: <69E30359-C87F-11D8-B399-000A95A0F1E8@randallsquared.com> On Jun 27, 2004, at 4:44 PM, Nathan Froyd wrote: > On Sun, Jun 27, 2004 at 02:36:06PM -0400, Randall Randall wrote: >> On Jun 27, 2004, at 8:58 AM, Joe Marshall wrote: >>> This isn't thread safe. If two processes attempted to enter the >>> queue >>> simultaneously, one could get lost. >> >> Because the second could run between evaluation of [the contents of] >> ,queue and evaluation of APPEND? Okay. Is there >> an atomic way to do that append such that it is >> thread safe without using specialized machinery not >> available with serve-event? > > CMUCL under x86 supports several "set place atomically" primitives > that use the processor's cmpxchg instruction to provide true > atomicity. (apropos "ATOMIC-") to have a peek at what's there. > Since you're on PPC, this may not help that much... My current method of dealing with the differences of CMUCL on PPC and x86 is to use serve-event on CMUCL, so that I have only one kind of difference (MP vs. non-MP). Given that I'm using serve-event, in which control must be explicitly passed, I shouldn't need any further effort to be effectively atomic on CMUCL. I would have preferred to have a single operation I could do on all CLs that would guarantee atomicity of an operation whether or not multiprocessing was involved, but I understand that it isn't covered by ANSI. The thread-safe (I think) version of ENQUEUE is: (defmacro enqueue (queue) "Appends a unique ID to a queue." (let ((id (gensym))) `(let ((,id (gensym))) #+(and acl-compat (not allegro) (not cmu)) (ACL-COMPAT.MP:without-interrupts (setf ,queue (append ,queue (list ,id)))) #+allegro (MP:without-interrupts (setf ,queue (append ,queue (list ,id)))) #+cmu (setf ,queue (append ,queue (list ,id))) ,id))) -- Randall Randall (706) 536-2674 Remote administration -- web applications -- consulting