Subject: Re: How to read a binary floating-point file?
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 26 Jul 2006 23:25:16 -0500
Newsgroups: comp.lang.lisp
Message-ID: <9NKdnZZs4Jex3VXZnZ2dnUVZ_qOdnZ2d@speakeasy.net>
James Bielman  <jamesjb@jamesjb.com> wrote:
+---------------
| You may also need to look into disabling garbage collection or
| instructing the GC not to move your array for the duration of the
| system call, for maximum safety.  I don't know about CMUCL, but in
| SBCL I would suggest the use of WITH-PINNED-OBJECTS.
+---------------

    cmu> (describe 'system:without-gcing)

    WITHOUT-GCING is an external symbol in the SYSTEM package.
    Macro-function: #<Function (:MACRO SYSTEM:WITHOUT-GCING) {102BE7A9}>
    Macro arguments:
      (&rest body)
    Macro documentation:
      Executes the forms in the body without doing a garbage collection.
    ...
    cmu> 

This should surround the call to (%FREAD (SYS:VECTOR-SAP array) ...).

Though note that in compiled code, VECTOR-SAP doesn't cons.
So since CMUCL is single-threaded (from the OS/s POV), in practice
it's safe even without the SYSTEM:WITHOUT-GCING, provided all the
other arguments to %FREAD have been precomputed as well. [This is
probably *not* the case in SBCL on platforms on which it supports
native threading.]


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607