Implemented times

now uses system_time, because we don't have to return a real time


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10242 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2004-11-25 20:16:35 +00:00
parent 4693e9c7a5
commit 82f223ea8c
+25 -10
View File
@@ -1,24 +1,39 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. ** Copyright 2004, Jérô Duval, [email protected].
** Distributed under the terms of the Haiku License. ** Copyright 2004, Axel Dörfler, [email protected]e.
** Distributed under the terms of the MIT License.
*/ */
#include <OS.h> #include <OS.h>
#include <errno.h>
#include <sys/resource.h>
#include <sys/times.h> #include <sys/times.h>
#include <time.h>
clock_t clock_t
times(struct tms *buffer) times(struct tms *buffer)
{ {
// ToDo: get some real values here! team_usage_info info;
buffer->tms_utime = 0; status_t err;
buffer->tms_stime = 0; int32 clk_tck = 1000000 / CLK_TCK; /* to avoid overflow */
buffer->tms_cutime = 0;
buffer->tms_cstime = 0;
return real_time_clock() * CLK_TCK; if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_SELF, &info)) != B_OK) {
errno = err;
return -1;
}
buffer->tms_utime = info.user_time / clk_tck;
buffer->tms_stime = info.kernel_time / clk_tck;
if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_CHILDREN, &info)) != B_OK) {
errno = err;
return -1;
}
buffer->tms_cutime = info.user_time / clk_tck;
buffer->tms_cstime = info.kernel_time / clk_tck;
return system_time() / clk_tck;
} }