[R] niceness

Charles Geyer charlie at stat.umn.edu
Fri Jan 21 20:21:45 CET 2005


Can anyone tell me if the following C code (which proved very useful when
using the snow package -- use it to nice slaves) compiles and dyn.loads
under Windoze or Mac?  It is (apparently) POSIX, so I suppose it is fine
in OS X, but does Windoze's advertized POSIX compliance mean anything here?

If it doesn't work on some platform, how do I deal with that?  I want
to submit as contributed package to CRAN.  The whole package can be found at

    http://www.stat.umn.edu/geyer/nice_0.1.tar.gz

----- begin C code file -----

#include <sys/resource.h>
#include <errno.h>
#include <string.h>
#include <R.h>

void
get_my_priority(int *result)
{
    errno = 0;
    result[0] = getpriority(PRIO_PROCESS, 0);
    if (errno != 0)
        warning(strerror(errno));
}

void
set_my_priority(int *priority)
{
    if (setpriority(PRIO_PROCESS, 0, priority[0]) != 0)
        warning(strerror(errno));
}

------ end C code file ------

-- 
Charles Geyer
Professor, School of Statistics
University of Minnesota
charlie at stat.umn.edu




More information about the R-help mailing list