I am having a legacy function(which is given below) to find the tick count, that means how much time the system is up.
long findtick() { struct tms buf; clock_t tickcount = 0; tickcount = times(&buf); return (long)tickcount; }
I am not able to find the behaviour of times
system call and clock_t
structure type.
My doubts are
times
system call in linux. clock_t
signed long
I am using gcc
compiler in suse 10.
What is the behaviour and return value of times system call in linux.
Ans : times
What is the structure definition of clock_t
Ans : typedef clock_t long
which is defined in ctime.h
Will this function return tickcount in seconds?
Ans : yes
By any chance can this function return -1
, because its return type is signed long
Ans : In failure case, times
will return -1
Thanks @cnicutar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.