From: Tim Bradshaw
Subject: GET-INTERNAL-RUN-TIME in CMUCL 17f / Solaris 2.5?
Date: 
Message-ID: <ey3pw0z7def.fsf@staffa.aiai.ed.ac.uk>
GET-INTERNAL-RUN-TIME returns 0 with CMUCL 17f on a sparc 5 running
Solaris 2.5.  Does anyone have a fix for this?

Thanks

--tim

From: Martin Cracauer
Subject: Re: GET-INTERNAL-RUN-TIME in CMUCL 17f / Solaris 2.5?
Date: 
Message-ID: <1996Nov28.124800.29136@wavehh.hanse.de>
Tim Bradshaw <···@aiai.ed.ac.uk> writes:

>GET-INTERNAL-RUN-TIME returns 0 with CMUCL 17f on a sparc 5 running
>Solaris 2.5.  Does anyone have a fix for this?

The problem is that noone interfaced getrusage() on Solaris, but it
should not be too hard to do if you look over the sources for SunOS
and Solaris in comparision. 

This is a fix to get CMUCL's (time ...) function to report user and
system cputime, maybe that's sufficient for your needs.

~To: ··········@cs.cmu.edu
~Cc: Casper Dik <······@fwi.uva.nl>
~Subject: Bug (and fix) for cmucl-17f TIME (sunos5, alpha)
~Date: Fri, 25 Nov 1994 11:51:59 PST
~From: Andreas Stolcke <·······@ICSI.Berkeley.EDU>
~Status: RO


TIME in the solaris port doesn't report user and system cputime,
due to getrusage() lossage in solaris.  GET-INTERNAL-RUN-TIME
is also affected.  The patch below uses the times(2) system call
instead.
(Still no page fault statistics, sorry).

On alphas, TIME breaks because SYSTEM:GET-SYSTEM-INFO always returns
NIL.
This is probably just a typo.

--Andreas


;;;
;;; Addition to code/unix.lisp: support for times(2) system call
;;;

(in-package "UNIX")

(export '(unix-times unix-time-units-per-second))

;;; From sys/times.h

(def-alien-type nil
  (struct tms
    (tms-utime #-alpha long #+alpha int)        ; user time used
    (tms-stime #-alpha long #+alpha int)        ; system time used.
    (tms-cutime #-alpha long #+alpha int)       ; user time, children
    (tms-cstime #-alpha long #+alpha int)))     ; system time,
children

(defconstant unix-time-units-per-second 100
  "Machine-dependent units in which unix-times results are returned,
  not necessarily equal to internal-time-units-per-second")

#+(and sparc svr4)
(defun unix-times ()
  "Unix-times returns information about the cpu time usage
   of the process and its children. NIL and an error number
   is returned if the call fails."
  (with-alien ((usage (struct tms)))
    (syscall* ("times" (* (struct tms)))
              (values t
                      (slot usage 'tms-utime)
                      (slot usage 'tms-stime)
                      (slot usage 'tms-cutime)
                      (slot usage 'tms-cstime))
              (addr usage))))

;;;
;;; Fix to code/time.lisp
;;;

(in-package "SYSTEM")

;;; GET-SYSTEM-INFO  --  Interface
;;;
;;;    Return system time, user time and number of page faults.
;;;
#+(and sparc svr4)
(defun get-system-info ()
  (multiple-value-bind
      (err? utime stime cutime cstime)
      (unix:unix-times)
    (declare (ignore cutime cstime))
    (cond ((null err?)
           (error "Unix system call times failed: ~A."
                  (unix:get-unix-error-msg utime)))
          (T
           ;; return times in microseconds for getrusage compatibility
           ;; bummer: page fault statistics not supported
           (values (truncate (* utime 1000000)
unix:unix-time-units-per-second)
                   (truncate (* stime 1000000)
unix:unix-time-units-per-second)
                   0)))))

#+osf1
;; this definition is botched in the original
(defun get-system-info ()
  (multiple-value-bind (err? utime stime maxrss ixrss idrss
                             isrss minflt majflt)
                       (unix:unix-getrusage unix:rusage_self)
    (declare (ignore maxrss ixrss idrss isrss minflt))
    (unless err?
      (error "Unix system call getrusage failed: ~A."
             (unix:get-unix-error-msg utime)))

    (values utime stime majflt)))


-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
···············@wavehh.hanse.de http://cracauer.cons.org  Fax.: +4940 5228536
"As far as I'm concerned,  if something is so complicated that you can't ex-
 plain it in 10 seconds, then it's probably not worth knowing anyway"- Calvin
From: Casper H.S. Dik - Network Security Engineer
Subject: Re: GET-INTERNAL-RUN-TIME in CMUCL 17f / Solaris 2.5?
Date: 
Message-ID: <casper.849525144@uk-usenet.uk.sun.com>
Tim Bradshaw <···@aiai.ed.ac.uk> writes:

>GET-INTERNAL-RUN-TIME returns 0 with CMUCL 17f on a sparc 5 running
>Solaris 2.5.  Does anyone have a fix for this?

None other than recompiling lisp.

What I did when porting CMU lisp to Solaris was adding some shortcuts to
the solaris code to satisfy some symbols, one of such was giving a no-op
getrusage.

In 2.5, there's a getrusage in libc you can use.  I've send in some patches
for 2.5 (also needed to support teh UltraSPARC) and those also add
a working get-external-runtime.)

(Check www.cons.org, they should be somewhere there)

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
From: Andreas Stolcke
Subject: Re: GET-INTERNAL-RUN-TIME in CMUCL 17f / Solaris 2.5?
Date: 
Message-ID: <582vui$64r@unix.sri.com>
In article <················@uk-usenet.uk.sun.com>,
Casper H.S. Dik - Network Security Engineer <··········@Holland.Sun.COM> wrote:
>Tim Bradshaw <···@aiai.ed.ac.uk> writes:
>
>>GET-INTERNAL-RUN-TIME returns 0 with CMUCL 17f on a sparc 5 running
>>Solaris 2.5.  Does anyone have a fix for this?
>
>None other than recompiling lisp.
>
>What I did when porting CMU lisp to Solaris was adding some shortcuts to
>the solaris code to satisfy some symbols, one of such was giving a no-op
>getrusage.

I reimplemented GET-INTERNAL-RUN-TIME on top of the times(2) systems call.
This works just fine.  (See the patch someone posted as the first
followup to the orignal post here).

-- 
Andreas Stolcke                                 ·······@speech.sri.com
Speech Technology and Research Laboratory       Phone (415) 859-2544
SRI International, Menlo Park, CA 94025, USA    Fax (415) 859-5984
From: Martin Cracauer
Subject: Re: GET-INTERNAL-RUN-TIME in CMUCL 17f / Solaris 2.5?
Date: 
Message-ID: <1996Dec4.103114.21137@wavehh.hanse.de>
·······@speech.sri.com (Andreas Stolcke) writes:

>In article <················@uk-usenet.uk.sun.com>,
>Casper H.S. Dik - Network Security Engineer <··········@Holland.Sun.COM> wrote:
>>Tim Bradshaw <···@aiai.ed.ac.uk> writes:
>>
>>>GET-INTERNAL-RUN-TIME returns 0 with CMUCL 17f on a sparc 5 running
>>>Solaris 2.5.  Does anyone have a fix for this?
>>
>>None other than recompiling lisp.
>>
>>What I did when porting CMU lisp to Solaris was adding some shortcuts to
>>the solaris code to satisfy some symbols, one of such was giving a no-op
>>getrusage.

>I reimplemented GET-INTERNAL-RUN-TIME on top of the times(2) systems call.
>This works just fine.  (See the patch someone posted as the first
>followup to the orignal post here).

I think once again this is good time to note that I am willing to
build a CMUCL/Solaris version with all the fixes for Ultrasparc,
timing etc., but I need access to an Ultrasparc machine, I don't have
one.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
···············@wavehh.hanse.de http://cracauer.cons.org  Fax.: +4940 5228536
"As far as I'm concerned,  if something is so complicated that you can't ex-
 plain it in 10 seconds, then it's probably not worth knowing anyway"- Calvin
From: Marco Antoniotti
Subject: Re: GET-INTERNAL-RUN-TIME in CMUCL 17f / Solaris 2.5?
Date: 
Message-ID: <s08enh3qzya.fsf@salmon.ICSI.Berkeley.EDU>
········@wavehh.hanse.de (Martin Cracauer) writes:

> 
> ·······@speech.sri.com (Andreas Stolcke) writes:
> 
> >In article <················@uk-usenet.uk.sun.com>,
> >Casper H.S. Dik - Network Security Engineer <··········@Holland.Sun.COM> wrote:
> >>Tim Bradshaw <···@aiai.ed.ac.uk> writes:
> >>

> >>What I did when porting CMU lisp to Solaris was adding some shortcuts to
> >>the solaris code to satisfy some symbols, one of such was giving a no-op
> >>getrusage.
> 

> 
> I think once again this is good time to note that I am willing to
> build a CMUCL/Solaris version with all the fixes for Ultrasparc,
> timing etc., but I need access to an Ultrasparc machine, I don't have
> one.

If you are doing some specific work assuming to use 'getrusage' under
Solaris just don't.  I just bumped into it a few days ago.  From the
comments in the include file it looks like some of the fields of the
rusage structure are invariably set to 0 in Solaris and stay like that.

I used the /proc inquiry functionalities (via 'ioctl') instead and
they seem to be working much more nicely.  Beside they also seem to be
more portable across FreeBSD and Linux platforms.

Cheers

-- 
Marco Antoniotti - Resistente Umano
===============================================================================
International Computer Science Institute	| ·······@icsi.berkeley.edu
1947 Center STR, Suite 600			| tel. +1 (510) 643 9153
Berkeley, CA, 94704-1198, USA			|      +1 (510) 642 4274 x149
===============================================================================
	...it is simplicity that is difficult to make.
	...e` la semplicita` che e` difficile a farsi.
				Bertholdt Brecht
From: Casper H.S. Dik - Network Security Engineer
Subject: Re: GET-INTERNAL-RUN-TIME in CMUCL 17f / Solaris 2.5?
Date: 
Message-ID: <casper.850212379@uk-usenet.uk.sun.com>
Marco Antoniotti <·······@salmon.icsi.berkeley.edu> writes:

>If you are doing some specific work assuming to use 'getrusage' under
>Solaris just don't.  I just bumped into it a few days ago.  From the
>comments in the include file it looks like some of the fields of the
>rusage structure are invariably set to 0 in Solaris and stay like that.

Only the *rss fields are always 0, the rest (such as those needed
for get-internal-runtime) are set to sane value.

BTW, if you want to build CMUCL for an UltraSPARC, all you need is a
Solaris 2.5/SPARC system and make sure you include the UltraSPARC
fixup in the illegal instruction handler.

I can't lend yo an Ultra for building, but I can get my hands on one for
testing, and testing it on one all you really need.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.