summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-02-02 07:43:39 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-02-02 07:48:49 +0100
commit1e483a62ea30e49e9d63ffdd44b14ac4a15f4fe3 (patch)
tree6723ca753d3a87922e7fc8877244b30df82ddedb /cpukit/libmisc
parentsmpschedaffinity04: Fix configuration (diff)
downloadrtems-1e483a62ea30e49e9d63ffdd44b14ac4a15f4fe3.tar.bz2
test: Add rtems_test_busy_cpu_usage()
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r--cpukit/libmisc/testsupport/testbusy.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/cpukit/libmisc/testsupport/testbusy.c b/cpukit/libmisc/testsupport/testbusy.c
index 2d34a805dc..4cc8aa01fe 100644
--- a/cpukit/libmisc/testsupport/testbusy.c
+++ b/cpukit/libmisc/testsupport/testbusy.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -19,6 +19,7 @@
#include <rtems/test.h>
#include <rtems.h>
+#include <rtems/score/threadimpl.h>
static uint_fast32_t estimate_busy_loop_maximum( void )
{
@@ -105,3 +106,19 @@ uint_fast32_t rtems_test_get_one_tick_busy_count( void )
return m;
}
+
+void rtems_test_busy_cpu_usage( time_t seconds, long nanoseconds )
+{
+ Thread_Control *executing;
+ Timestamp_Control busy;
+ Timestamp_Control start;
+ Timestamp_Control now;
+
+ executing = _Thread_Get_executing();
+ _Thread_Get_CPU_time_used( executing, &start );
+ _Timestamp_Set( &busy, seconds, nanoseconds );
+
+ do {
+ _Thread_Get_CPU_time_used( executing, &now );
+ } while ( now - start < busy );
+}