Sys.sleep waits forever + workaround (PR#8678)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Sys.sleep waits forever + workaround (PR#8678)

westfeld
When I tried to schedule a calculation for the next day (waiting several
10000 seconds), I noticed that Sys.sleep does never return (R version
2.1.0 on Linux). From the C code I expect that the maximum number of
seconds is about 2000 (2^31/1e6), which is system-dependent.

##Sys.sleep <- function(time)
##    invisible(.Internal(Sys.sleep(time)))

Sys.sleep <- function(time) {
        nloops <- time%/%1000
        while (nloops>0) {
                nloops <- nloops-1
                .Internal(Sys.sleep(1000))
        }
        invisible(.Internal(Sys.sleep(time%%1000)))
}


--
Andreas Westfeld, 0432 01CC F511 9E2B 0B57 5993 0B22 98F8 4AD8 EEEA
<[hidden email]> http://www.inf.tu-dresden.de/~aw4
TU Dresden Fakultät Informatik, Institut für Systemarchitektur
Datenschutz und Datensicherheit, Tel. +49-351-463-37918

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sys.sleep waits forever + workaround (PR#8678)

Brian Ripley
On Mon, 13 Mar 2006, [hidden email] wrote:

> When I tried to schedule a calculation for the next day (waiting several
> 10000 seconds), I noticed that Sys.sleep does never return (R version
> 2.1.0 on Linux). From the C code I expect that the maximum number of
> seconds is about 2000 (2^31/1e6), which is system-dependent.

Actually, it is not: is always (2^31-1)/1e6.

This is easy to fix at C level, and I have done so.

>
> ##Sys.sleep <- function(time)
> ##    invisible(.Internal(Sys.sleep(time)))
>
> Sys.sleep <- function(time) {
>        nloops <- time%/%1000
>        while (nloops>0) {
>                nloops <- nloops-1
>                .Internal(Sys.sleep(1000))
>        }
>        invisible(.Internal(Sys.sleep(time%%1000)))
> }
>
>
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel