[M3devel] Uresource on freebsd 4?

Jay jay.krell at cornell.edu
Sat Apr 25 10:01:12 CEST 2009


I should have read the docs first.

 

http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/resource.h.html

 

 

Only guarantees ru_utime and ru_stime.

So maybe a portable wrapper isn't such a bad idea, since it'd only copy back so little.

 

The various time_t, struct timeval, struct tm, struct itimerval, are some of the only system-dependent code/types remaining but maybe I should have to live with them not going away.

Maybe. Modula-3 does layer over all of these anyway so more "refactoring" can probably remove them all. (ie: pushing some of the wrapping up to libm3).

 

 

But if that's adequate -- exposing just ru_utime and ru_stime, then so is probably the old RTProcessPosix.

 

 

 - Jay
 


From: jay.krell at cornell.edu
To: mika at async.caltech.edu
CC: m3devel at elegosoft.com
Subject: RE: [M3devel] Uresource on freebsd 4?
Date: Sat, 25 Apr 2009 07:52:31 +0000



Does something like this suffice?
Seconds used by current process as a float (including sub-second resolution).
 
 
http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/runtime/POSIX/Attic/RTProcessPosix.i3?rev=1.1;content-type=text%2Fplain
 
 
http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/runtime/POSIX/Attic/RTProcessPosixC.c?rev=1.7;content-type=text%2Fplain


Notice it is in Attic.
 
 
If not, can you write your own similar?
 
 
The full getrusage has that huge struct.. seems best to not expose the whole thing but have folks write little C wrappers for just what they need. A portable wrapper would copy out all the fields, for "all the fields" defined as all the ones implemented by all systems. Only to have most users probably ignore most of them.
 
 
Notice the cruft:
 
 
  struct_rusage = RECORD
    ru_utime: Utime.struct_timeval;  (* user time used *)
    ru_stime: Utime.struct_timeval;  (* system time used *)
    ru_maxrss: long;
    ru_ixrss: long;            (* integral shared text size *)
    (* Unsupported in Linux 1.0:
    ru_ismrss: long;           (* integral shared memory size*)
    ******************************)

 
kind of makes you wonder....when the FreeBSD path has stuff commented out because Linux 1.0 doesn't support it, which parts are correct?
And is it still correct in FreeBSD 5, 6, 7, 9, 10? (Did it get copied blindly to other directoryes, like maybe Darwin?)
 
 
I guess the only client used utime and stime (based on the code in the Attic).
Mistakes here -- such as commenting out fields that are actually there -- would generally result in stack corruption, which might be ok, on some days, on some systems, with some compilers, with some compiler flags, depending on what is nearby on the stack, and what it gets overwritten with. Very dangerous stuff..
 
 
For Win32, lookup GetProcessTimes and GetThreadTimes.
 
 
getrlimit doesn't look so problematic, at least based on the FreeBSD4 version.
 
 
(Something is really weird with mail encoding, could be me, using a variety of modern mail clients..)
 
 
 - Jay
 
> To: jay.krell at cornell.edu
> Date: Fri, 24 Apr 2009 23:32:29 -0700
> From: mika at async.caltech.edu
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] Uresource on freebsd 4?
> 
> 
> I use it for timing programs (getrusage). Is there another way of
> doing that in Modula-3?
> 
> This declaration:
> 
> <*EXTERNAL*> PROCEDURE getrusage (who: int; VAR rus: struct_rusage): int;
> 
> I'm sure getrlimit is useful too.
> 
> These things have been in Modula-3 for a long time...
> 
> It's the only thing that's missing that I personally use. Except
> for some disturbances in m3tk things are now compiling for me...
> 
> Mika
> 
> 
> Jay writes:
> >--_55ac72c8-d027-4bd6-a303-434a73dcc5db_
> >Content-Type: text/plain; charset="iso-8859-1"
> >Content-Transfer-Encoding: quoted-printable
> >
> >
> >Do you need it?
> >
> >Is there a sufficient common/Uresource.i3?
> >
> >=20
> >
> >I generally removed whatever isn't used=2C and made the remainders portable=
> >.
> >
> >I can look into restoring more=2C but what do you need and what is there? (=
> >I can look.)
> >
> >=20
> >
> >=20
> >
> > - Jay
> >
> >=20
> >> To: m3devel at elegosoft.com
> >> Date: Fri=2C 24 Apr 2009 22:58:23 -0700
> >> From: mika at async.caltech.edu
> >> CC: mika at camembert.async.caltech.edu
> >> Subject: [M3devel] Uresource on freebsd 4?
> >>=20
> >>=20
> >> Is there any particular reason Uresource no longer exists on FreeBSD4?
> >> The m3makefile
> >>=20
> >> m3core/src/unix/freebsd-4/m3makefile
> >>=20
> >> looks like the following=2C and Uresource isn't picked up anywhere else:
> >>=20
> >> if TRUE
> >>=20
> >> Module ("Usignal")
> >> Interface ("Uucontext")
> >>=20
> >> else
> >>=20
> >> Interface ("Udir")
> >> Interface ("Uerror")
> >> %Interface ("Ugrp")
> >> Interface ("Uipc")
> >> Interface ("Umman")
> >> Module ("Umsg")
> >> Interface ("Unix")
> >> Interface ("Uprocess")
> >> Interface ("Upthread")
> >> Interface ("Upwd")
> >> Interface ("Uresource")
> >> Interface ("Usem")
> >> Interface ("Usched")
> >> Interface ("Ushm")
> >> Module ("Usignal")
> >> Interface ("Ustat")
> >> Interface ("Usocket")
> >> Interface ("Usyslog")
> >> Interface ("Utime")
> >> Module ("Utypes")
> >> Interface ("Uucontext")
> >> Interface ("Uugid")
> >> Interface ("Uuio")
> >> Interface ("Uutsname")
> >>=20
> >> end
> >>=20
> >
> >--_55ac72c8-d027-4bd6-a303-434a73dcc5db_
> >Content-Type: text/html; charset="iso-8859-1"
> >Content-Transfer-Encoding: quoted-printable
> >
> ><html>
> ><head>
> <style>
> >.hmmessage P
> >{
> >margin:0px=3B
> >padding:0px
> >}
> >body.hmmessage
> >{
> >font-size: 10pt=3B
> >font-family:Verdana
> >}
> ></style>
> ></head>
> ><body class=3D'hmmessage'>
> >Do you need it?<BR>
> >Is there a sufficient common/Uresource.i3?<BR>
> >&nbsp=3B<BR>
> >I generally removed whatever isn't used=2C and made the remainders portable=
> >.<BR>
> >I can look into restoring more=2C but what do you need and what is there? (=
> >I can look.)<BR>
> >&nbsp=3B<BR>
> >&nbsp=3B<BR>
> >&nbsp=3B- Jay<BR><BR>&nbsp=3B<BR>&gt=3B To: m3devel at elegosoft.com<BR>&gt=3B=
> > Date: Fri=2C 24 Apr 2009 22:58:23 -0700<BR>&gt=3B From: mika at async.caltech=
> >.edu<BR>&gt=3B CC: mika at camembert.async.caltech.edu<BR>&gt=3B Subject: [M3d=
> >evel] Uresource on freebsd 4?<BR>&gt=3B <BR>&gt=3B <BR>&gt=3B Is there any =
> >particular reason Uresource no longer exists on FreeBSD4?<BR>&gt=3B The m3m=
> >akefile<BR>&gt=3B <BR>&gt=3B m3core/src/unix/freebsd-4/m3makefile<BR>&gt=3B=
> > <BR>&gt=3B looks like the following=2C and Uresource isn't picked up anywh=
> >ere else:<BR>&gt=3B <BR>&gt=3B if TRUE<BR>&gt=3B <BR>&gt=3B Module ("Usigna=
> >l")<BR>&gt=3B Interface ("Uucontext")<BR>&gt=3B <BR>&gt=3B else<BR>&gt=3B <=
> >BR>&gt=3B Interface ("Udir")<BR>&gt=3B Interface ("Uerror")<BR>&gt=3B %Inte=
> >rface ("Ugrp")<BR>&gt=3B Interface ("Uipc")<BR>&gt=3B Interface ("Umman")<B=
> >R>&gt=3B Module ("Umsg")<BR>&gt=3B Interface ("Unix")<BR>&gt=3B Interface (=
> >"Uprocess")<BR>&gt=3B Interface ("Upthread")<BR>&gt=3B Interface ("Upwd")<B=
> >R>&gt=3B Interface ("Uresource")<BR>&gt=3B Interface ("Usem")<BR>&gt=3B Int=
> >erface ("Usched")<BR>&gt=3B Interface ("Ushm")<BR>&gt=3B Module ("Usignal")=
> ><BR>&gt=3B Interface ("Ustat")<BR>&gt=3B Interface ("Usocket")<BR>&gt=3B In=
> >terface ("Usyslog")<BR>&gt=3B Interface ("Utime")<BR>&gt=3B Module ("Utypes=
> >")<BR>&gt=3B Interface ("Uucontext")<BR>&gt=3B Interface ("Uugid")<BR>&gt=
> >=3B Interface ("Uuio")<BR>&gt=3B Interface ("Uutsname")<BR>&gt=3B <BR>&gt=
> >=3B end<BR>&gt=3B <BR></body>
> ></html>=
> >
> >--_55ac72c8-d027-4bd6-a303-434a73dcc5db_--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090425/1275171b/attachment-0002.html>


More information about the M3devel mailing list