rda654z@monu6.cc.monash.edu.au (Evan McLean) (05/27/91)
[NOTE :- I'm reposting this as our outside links were playing up over the weekend. Apologies to those who read this twice] 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. Does anybody know or has code/patches to allow a user program to find out the number of clock ticks a process has been running for (or alternatively, the number of clock ticks from some common reference point?) 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 want, unfortunately, I have not been able to find the source for this in the libraries... Any help would be appreciated. Thanks in advance. Evan McLean -- Wendigo (Sometimes known as Evan McLean) | "Would you like a bag with that?" [ Occasionally thought of as | "No thanks, I'll throw up rda654z@monu6.cc.monash.edu.au ] | in the packet." Monash University (Caulfield Campus) | -- Terry ordering MacDonalds --- Random quote to follow ---------------------------------------------------- When any principle, law, tenet, probability, happening, circumstance, or result can in no way be directly, indirectly, empirically, or circuitously proven, derived, implied, inferred, induced, deducted, estimated, or scientifically guessed, it will always for the purpose of convenience, expediency, political advantage, material gain, or personal comfort, or any combination of the above, or none of the above, be unilaterally and unequivocally assumed, proclaimed, and adhered to as absolute truth to be undeniably, universally, immutably, and infinitely so, until such time as it becomes advantageous to assume otherwise, maybe. -- Rhode's Law
evans@syd.dit.CSIRO.AU (Bruce.Evans) (05/27/91)
>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
hp@vmars.tuwien.ac.at (Peter Holzer) (05/27/91)
rda654z@monu6.cc.monash.edu.au (Evan McLean) writes: >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. >Does anybody know or has code/patches to allow a user program to find out the >number of clock ticks a process has been running for (or alternatively, the >number of clock ticks from some common reference point?) Soon after 1.5 came out I noticed this bug, too. I posted patches to fix it. If you can't find them in an archive near you, they are at ftp.vmars.tuwien.ac.at in file /pub/minix/hp/times.patches. Times now returns the time in ticks since boot time. BTW, Andy, did these patches make it into Minix 1.6? -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technical University Vienna | as evolution | | | | | Dept. for Real-Time Systems | in action! | | __/ | hp@vmars.tuwien.ac.at | Tony Rand |