[M3devel] Uresource on freebsd 4?
Jay
jay.krell at cornell.edu
Sat Apr 25 09:52:31 CEST 2009
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>
> > =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>
> > =3B<BR>
> > =3B<BR>
> > =3B- Jay<BR><BR> =3B<BR>>=3B To: m3devel at elegosoft.com<BR>>=3B=
> > Date: Fri=2C 24 Apr 2009 22:58:23 -0700<BR>>=3B From: mika at async.caltech=
> >.edu<BR>>=3B CC: mika at camembert.async.caltech.edu<BR>>=3B Subject: [M3d=
> >evel] Uresource on freebsd 4?<BR>>=3B <BR>>=3B <BR>>=3B Is there any =
> >particular reason Uresource no longer exists on FreeBSD4?<BR>>=3B The m3m=
> >akefile<BR>>=3B <BR>>=3B m3core/src/unix/freebsd-4/m3makefile<BR>>=3B=
> > <BR>>=3B looks like the following=2C and Uresource isn't picked up anywh=
> >ere else:<BR>>=3B <BR>>=3B if TRUE<BR>>=3B <BR>>=3B Module ("Usigna=
> >l")<BR>>=3B Interface ("Uucontext")<BR>>=3B <BR>>=3B else<BR>>=3B <=
> >BR>>=3B Interface ("Udir")<BR>>=3B Interface ("Uerror")<BR>>=3B %Inte=
> >rface ("Ugrp")<BR>>=3B Interface ("Uipc")<BR>>=3B Interface ("Umman")<B=
> >R>>=3B Module ("Umsg")<BR>>=3B Interface ("Unix")<BR>>=3B Interface (=
> >"Uprocess")<BR>>=3B Interface ("Upthread")<BR>>=3B Interface ("Upwd")<B=
> >R>>=3B Interface ("Uresource")<BR>>=3B Interface ("Usem")<BR>>=3B Int=
> >erface ("Usched")<BR>>=3B Interface ("Ushm")<BR>>=3B Module ("Usignal")=
> ><BR>>=3B Interface ("Ustat")<BR>>=3B Interface ("Usocket")<BR>>=3B In=
> >terface ("Usyslog")<BR>>=3B Interface ("Utime")<BR>>=3B Module ("Utypes=
> >")<BR>>=3B Interface ("Uucontext")<BR>>=3B Interface ("Uugid")<BR>>=
> >=3B Interface ("Uuio")<BR>>=3B Interface ("Uutsname")<BR>>=3B <BR>>=
> >=3B end<BR>>=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/d10661ca/attachment-0002.html>
More information about the M3devel
mailing list