cputime on a SunOS-5.5 machine

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

cputime on a SunOS-5.5 machine

niles-5

OK well here's a semi- bug report for you all.

octave:1> getrusage
octave:2> whos
octave:3>

This doesn't seem to get defined on my SunOS-5.5 and HPUX-9 machines.
Therefore cputime is broken.  Perhaps it would be more friendly to
have it check if getrusage() returns anything..However,

a = getrusage;
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 12, column 3

This may be a problem since you can't even try to assign anything to
it.  I think this should probably return the null vector [].  What do
you think?  Then one could check the length(a) != 0 then say something
like: "Sorry cputime is not available on this machine."

This a reason why NOT to use "cputime" in the bm.m program.

        Rick Niles.


Reply | Threaded
Open this post in threaded view
|

cputime on a SunOS-5.5 machine

Francesco Potorti`-9
   a = getrusage;
   error: value on right hand side of assignment is undefined
   error: evaluating assignment expression near line 12, column 3

There is no getrusage on my octave on alpha.  What were you trying to
do?

   This may be a problem since you can't even try to assign anything to
   it.  I think this should probably return the null vector [].  What do
   you think?  Then one could check the length(a) != 0 then say something
   like: "Sorry cputime is not available on this machine."

What has it to do with cputime?

   This a reason why NOT to use "cputime" in the bm.m program.

Is cputime broken on your version of octave?
--
Francesco Potorti`                  Voice:    +39-50-593203
Satellite Network Group             Operator: +39-50-593111
CNUCE-CNR, Via Santa Maria 36       Fax:      +39-50-904052(G3)/904051(G4)
56126 Pisa - Italy                  Email:    [hidden email]

Reply | Threaded
Open this post in threaded view
|

cputime on a SunOS-5.5 machine

John W. Eaton-6
Francesco Potorti` <[hidden email]> wrote:

: There is no getrusage on my octave on alpha.  What were you trying to
: do?

I think Rick must be using one of the snapshots.  In the current
sources there is a getrusage() function that returns a structure like
this:

  octave:3> getrusage ()
  ans =
  {
    nvcsw = 170
    nswap = 0
    ixrss = 22
    nivcsw = 35
    msgrcv = 0
    inblock = 648
    minflt = 447
    stime =
    {
      usec = 179584
      sec = 0
    }

    msgsnd = 0
    isrss = 4
    utime =
    {
      usec = 131760
      sec = 0
    }

    idrss = 168
    majflt = 52
    maxrss = 1272
    nsignals = 0
    oublock = 11
  }

but only if your system has the getrusage system call.  Also in the
current sources, cputime() is implemented in an M-file by calling
the built-in function getrusage().

In any case, cputime has always been implemented using the getrusage()
system call, so it does not work on all systems.  If you know of
systems that do not have getrusage() but do have ways to get some (or
all) of that information using different system functions, please let
me know.

I do know that Solaris has getrusage() in the BSD compatibility library,
but Octave's configure script isn't currently looking there.
Something more to fix...

jwe

Reply | Threaded
Open this post in threaded view
|

cputime on a SunOS-5.5 machine

Francesco Potorti`-9
John Eaton wrote:

   I think Rick must be using one of the snapshots.  In the current
   sources there is a getrusage() function that returns a structure like
   this:

        [long struct deleted.  The entries relevant to the cputime
        discussion are the system time and user time of the process.]

   [...]  In any case, cputime has always been implemented using the
   getrusage() system call, so it does not work on all systems.  If
   you know of systems that do not have getrusage() but do have ways
   to get some (or all) of that information using different system
   functions, please let me know.

There should be a similar system call on every unix system, because on
every unix system I know of the time(1) command exists and it gives
just that information.  On the Motorola Delta systemV R3 it is the
times(2) system call, in libc, whose man page says:

     times fills the structure pointed to by buffer with time-
     accounting information.  The following are the contents of
     this structure:

     struct    tms {
          time_t      tms_utime;
          time_t      tms_stime;
          time_t      tms_cutime;
          time_t      tms_cstime;
     };

An analogous times(3) exists on alpha, in libc, a times(2) exists on
HP with the same functionality, it also exists on
spiff.gnu.ai.mit.edu, a NEWS-OS system (a Sun, I suppose), which also
says it is obsoleted by getrusage, but is retained for compatibility.

Anyway, as far as I know, times(2) is present on every system, as it
is an historical unix system call and will never be dumped altogether,
so it can be safely used for cputime() and for getrusage() as well, at
least for the time fields of the structure.

--
Francesco Potorti`                  Voice:    +39-50-593203
Satellite Network Group             Operator: +39-50-593111
CNUCE-CNR, Via Santa Maria 36       Fax:      +39-50-904052(G3)/904051(G4)
56126 Pisa - Italy                  Email:    [hidden email]