From 9a8a70db792aeedae2363bca580ded341fa8480e Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare@rtems.org>
Date: Wed, 25 Feb 2015 14:52:10 -0500
Subject: [PATCH] libcsupport: scale times() call to microseconds
---
cpukit/libcsupport/src/__times.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/cpukit/libcsupport/src/__times.c b/cpukit/libcsupport/src/__times.c
index b92fd63..5a1f9eb 100644
a
|
b
|
clock_t _times( |
43 | 43 | struct tms *ptms |
44 | 44 | ) |
45 | 45 | { |
46 | | rtems_interval ticks; |
| 46 | rtems_interval ticks, us_per_tick; |
47 | 47 | Thread_Control *executing; |
48 | 48 | |
49 | 49 | if ( !ptms ) |
… |
… |
clock_t _times( |
54 | 54 | */ |
55 | 55 | |
56 | 56 | ticks = rtems_clock_get_ticks_since_boot(); |
| 57 | us_per_tick = rtems_configuration_get_microseconds_per_tick(); |
57 | 58 | |
58 | 59 | /* |
59 | 60 | * RTEMS technically has no notion of system versus user time |
… |
… |
clock_t _times( |
90 | 91 | &fractional_ticks |
91 | 92 | ); |
92 | 93 | _Thread_Enable_dispatch(); |
93 | | ptms->tms_utime = ticks_of_executing / 100; |
| 94 | ptms->tms_utime = ticks_of_executing * us_per_tick; |
94 | 95 | } |
95 | 96 | #else |
96 | 97 | executing = _Thread_Get_executing(); |
97 | | ptms->tms_utime = executing->cpu_time_used; |
| 98 | ptms->tms_utime = executing->cpu_time_used * us_per_tick; |
98 | 99 | #endif |
99 | | ptms->tms_stime = ticks; |
| 100 | ptms->tms_stime = ticks * us_per_tick; |
100 | 101 | ptms->tms_cutime = 0; |
101 | 102 | ptms->tms_cstime = 0; |
102 | 103 | |
103 | | return ticks; |
104 | | } |
| 104 | return ticks * us_per_tick; |
| 105 | } |
105 | 106 | |
106 | 107 | /** |
107 | 108 | * times() system call wrapper for _times() above. |