Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!metro!dmssyd.syd.dms.CSIRO.AU!ditsydh.syd.dit.CSIRO.AU!evans From: evans@syd.dit.CSIRO.AU (Bruce.Evans) Newsgroups: comp.os.minix Subject: Re: finding out the number of clock ticks Message-ID: <1991May27.050946.23546@syd.dit.CSIRO.AU> Date: 27 May 91 05:09:46 GMT References: <1991May27.004930.11455@monu6.cc.monash.edu.au> Organization: CSIRO Division of Info Tech, Sydney, Australia Lines: 29 >I'm trying to find a way to read the number of clock ticks since the start >of the program. The c function call "times" is suppose to return this, but >doesn't seem to. times() is not very portable. In SunOS and maybe BSD and V7, it only returns 0 for success and -1 for failure. For SysV, I think it returns the number of clock ticks since boot. The Minix 1.6.15 FS and kernel have changes to return this number. The (unreleased) ACK library threw away the count in the last version I saw. >Does anybody know or has code/patches to allow a user program to find out the I guess it's easier to wait for 1.6. The only way I can think of to get the tick counts from a user program is to read them out of /dev/kmem. >In one of the C header files (I think it was "/usr/include/time.h" there is a >prototype for the function "clock" which, to my understanding, returns the >number of clock ticks that a program has been running. This is exactly what I have not seen a correct and useful implementation of clock() for Minix. (The legal, useless version is 'return (time_t) -1'.) The one in the ACK library returns the same as times() for SysV-like systems. This is not good enough as the "time related to program startup" in the specification of clock(). The obvious fix is to call times() from crtso for _every_ program to get the starting time, and return 'times() - start_time' in clock(). This is wasteful. It's smaller for the kernel to remember the starting time. Only a small increment to kernel bloat :-). -- Bruce Evans evans@syd.dit.csiro.au