[net.lang.ada] CPU Timer on VADS Needed

Bryan@SU-SIERRA.ARPA.UUCP (07/13/86)

We have just acquired a Sequent B8000 running BSD4.2 Unix,
and the Verdix compiler.  Has anyone written a CPU timer
interface to Unix that can be called from Ada?  Would
appreciate any leads.  To be specific, we need a package
body that implements the following spec:

  package Cpu_Timer is
    function Cpu return Duration;
    -- returns accumulated Cpu for a process
  end Cpu_Timer;

Thanks in advance.   Doug & Geoff
-------

eric@burdvax.UUCP (Eric Marshall) (07/28/86)

	I couldn't reach Bryan@SU-SIERRA.ARPA, so I'm posting
it here. See 'man times' for more information. Hope this helps.


----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< -----

package cpu_timer is

  function cpu return duration;

end cpu_timer;

-------------------------------------------------------------------
 
with system;
use  system;
 
package body cpu_timer is 

  function cpu return duration is 

    type time_record is record
      user_time,
      system_time,
      children_user_time,
      children_system_time : integer;
    end record;

    answer : time_record;
 
    procedure times( param : address );
    pragma interface( c, times );

  begin 
    times( answer'address );

    return duration( duration( answer.user_time ) / duration( 60.0 ) );
                     ----------------------------
                                 |
                                 |
                                 ----- put the expression to meet your
                                       requirements regarding what CPU
                                       time is, ie. ( user_time +
                                                      system_time +
                                                      children_user_time +
                                                      children_system_time )
  end cpu;

end cpu_timer;