[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.21.11 Miscellaneous system calls

Function: sys-pause
[POSIX] Suspends the process until it receives a signal whose action is to either execute a signal-catching function or to terminate the process. This function only returns when the signal-catching function returns. The returned value is undefined.

Note that just calling pause() doesn't suffice the above semantics in Scheme-level. Internally this procedure calls sigsuspend() with the current signal mask.

Function: sys-alarm seconds
[POSIX] Arranges a SIGALRM signal to be delivered after seconds. The previous settings of the alarm clock is cancelled. Passing zero to seconds doesn't schedule new alarm. Returns the number of seconds remaining until previously scheduled alarm was due to be delivered (or zero if no alarm is active).

Function: sys-sleep seconds
[POSIX] Suspends the process until the specified number of seconds elapses, or the process receives a signal. Returns zero if it sleeps well, or the number of unslept seconds if it is woke up by a signal.

To be porable across POSIX implementation, keep seconds less than 65536.

Function: sys-nanosleep nanoseconds
[POSIX] Suspends the process until the specified number of nanoseconds elapses, or the process receives a signal. The argument nanoseconds can be a <time> object (See section 6.21.8.2 SRFI time), or a real number. Returns #f if nanoseconds elapsed, or a <time> object that indicates the remaining time if sys-nanosleep is interrupted by a signal.

 
;wait for 0.5 sec
(sys-nanosleep 500000000)

;wait for 1.3 sec
(sys-nanosleep (make <time> :second 1 :nanosecond 300000000)

Function: sys-random
Function: sys-srandom seed
A pseudo random number generator. sys-random returns a random number between 0 and a positive integer rand_max, inclusive. This is a straightforward interface to random(3). If the underlying system doesn't have random(3), lrand48(3) is used.

sys-srandom sets the seed of the random number generator. It uses either srandom(3) or srand48(3), depending on the system.

The intension of these functions are to provide an off-the-stock handy random number generator (RNG) for applications that doens't sensitive to the quality and/or speed of RNG. For serious statistics analysis, use Mersenne Twister RNG in math.mt-random module (See section 11.8 math.mt-random - Mersenne Twister Random number generator).

Variable: RAND_MAX
Bound to a positive integer that sys-random may return.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html