Ingvar | 4 Jun 2004 17:57
Picon

Web page revamp (and possible default-license-change)

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
Lawrence Mitchell | 11 Jun 2004 22:22
Picon
Gravatar

Eye-candy for gnus users.

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
(Continue reading)

Gary King | 24 Jun 2004 17:47
Picon
Favicon

Re: shuffle-vector

I like having both destructive and non-destructive versions:

(defun shuffle-vector (v)
   "Return copy of vector with elements shuffled like a deck of cards."
   (shuffle-vector! (copy-seq v)))

(defun shuffle-vector! (result)
   "Destructively shuffle elements in a vector like a deck of cards."
   (loop
     finally (return result)
     for i from (length result) downto 1
     as j = (random i)
     do (rotatef (svref result j) (svref result (1- i)))))

On Jun 24, 2004, at 10:03 AM, Ben Hyde wrote:

>
> (defun shuffle-vector (v)
>   "Return copy of vector with elements shuffled like a deck of cards."
>   (loop
>     with result = (copy-seq v)
>     finally (return result)
>     for i from (length v) downto 1
>     as j = (random i)
>     do (rotatef (svref result j) (svref result (1- i)))))
>
>
> That was fun.
>
>
(Continue reading)

Randall Randall | 27 Jun 2004 05:46

simple locking

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
(Continue reading)

Randall Randall | 27 Jun 2004 06:01

Re: simple locking


On Jun 26, 2004, at 11:46 PM, Randall Randall wrote:

And, of course, I sent to the wrong one.

My apologies.

--
Randall Randall <randall <at> randallsquared.com>
Property law should use #'EQ , not #'EQUAL .
Randall Randall | 27 Jun 2004 20:36

Re: [Small-cl-src] Re: simple locking retry


On Jun 27, 2004, at 8:58 AM, Joe Marshall wrote:

> Randall Randall <randall <at> randallsquared.com> 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.

(Continue reading)

Nathan Froyd | 27 Jun 2004 22:44

Re: Re: [Small-cl-src] Re: simple locking retry

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
Randall Randall | 27 Jun 2004 23:17

Re: simple locking retry

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:

(Continue reading)


Gmane