OS:within-critical-section, as well as reading and writing through TCP, uni- and bidirectional pipes.
A set of native Scheme procedures providing access to the common POSIX library facilities and UNIX system calls:
The source code documents the interfaces in full detail.
|The current version is 3.3, Aug 11, 2003.|
OS:for-each-file-in-directory DIR-NAME PROC
PROCon each file
file-info"object" that describes the file being scanned
#f, the scanning of the directory is terminated
'(), the scanning continues,
file-info object being given to the procedure
PROC is the result of
The object accepts the following "messages"
#tif the file is a directory
#tif the file is a block-special file, like those in
#tif the file is a char-special file, as
#tif the file is a plain regular file
#tif the file is a communication (
BIGNUM, generally, number, the number of seconds since Jan 1, 1970 (see
'others) and operation (
'exec), and tells if the file can be accessed by who with the operation
All i/o errors raise a
##SIGNAL.IO-ERROR, which can be
Verification code vreaddir.scm is a good example of using these functions; note a test case that uses
OS:for-each-file-in-directory to fake a "
ls -l ." UNIX command
These function use Gambit's
Scheme/C foreign function interface.
Current version: Apr 7, 1997
Click to download readdir.scm, and the verification code vreaddir.scm
The following higher-level i/o procedures capture several frequently-occurring patterns of input and output. The procedures proved convenient in practice. They are also efficient: Each procedure has a slow and a fast path implementations. The slow path code works with any i/o port and on any R4RS+ Scheme system. The fast path is specific to Gambit and to stream ports. The procedures themselves chose the right (the most optimal) path of execution.
|The current version is 3.0, May 2, 2001.|
Although there is no standard way of handling Unix/Posix signals in Scheme, many implementations, e.g., Gambit, let a user specify a thunk to execute whenever a signal, a timer interrupt or other external condition occurs.
Incidentally this makes it possible to write thread scheduling systems and the like directly in Scheme. Indeed, when a signal handler returns the interrupted computation resumes. The signal handler can therefore use its own continuation for thread switching purposes. Listing 1 in the article below shows the example of this idea. It uses non-preemptive "interrupts" and thus should run on every Scheme system. However, if you happen to have a Gambit-C system, you can insert Listing 2 into Listing 1 where indicated. This buys you a preemptive re-scheduling upon arrival of a user-defined signal. You can do "
|The current version is 1.1, Feb 26, 2000.|
A USENET article with the complete code and transcripts [plain text file]
|From other archives|
Gambit-C's foreign function interface
FIXNUM, the corresponding
BIGNUMis created. Conversely, both
FIXNUMcan be converted to C's
unsigned int(if they fit, of course).
oleg-at-pobox.com or oleg-at-okmij.org or oleg-at-computer.org