summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/resource_snapshot.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport/src/resource_snapshot.c')
-rw-r--r--cpukit/libcsupport/src/resource_snapshot.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c
index 6e4c4ca86f..6bba22671b 100644
--- a/cpukit/libcsupport/src/resource_snapshot.c
+++ b/cpukit/libcsupport/src/resource_snapshot.c
@@ -1,8 +1,8 @@
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
- * Obere Lagerstr. 30
+ * Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
@@ -22,13 +22,15 @@
#include <rtems/libio_.h>
#include <rtems/malloc.h>
+#include <rtems/score/rbtreeimpl.h>
#include <rtems/score/protectedheap.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/wkspace.h>
-#include <rtems/extensionimpl.h>
+#include <rtems/posix/keyimpl.h>
#include <rtems/rtems/barrierimpl.h>
+#include <rtems/extensionimpl.h>
#include <rtems/rtems/dpmemimpl.h>
#include <rtems/rtems/messageimpl.h>
#include <rtems/rtems/partimpl.h>
@@ -43,7 +45,6 @@
#include <rtems/posix/condimpl.h>
#include <rtems/posix/mqueueimpl.h>
#include <rtems/posix/muteximpl.h>
- #include <rtems/posix/keyimpl.h>
#include <rtems/posix/psignal.h>
#include <rtems/posix/pthreadimpl.h>
#include <rtems/posix/rwlockimpl.h>
@@ -52,7 +53,8 @@
#include <rtems/posix/timerimpl.h>
#endif
-static const Objects_Information *objects_info_table[] = {
+static const Objects_Information *const objects_info_table[] = {
+ &_POSIX_Keys_Information,
&_Barrier_Information,
&_Extension_Information,
&_Message_queue_Information,
@@ -67,7 +69,6 @@ static const Objects_Information *objects_info_table[] = {
,
&_POSIX_Barrier_Information,
&_POSIX_Condition_variables_Information,
- &_POSIX_Keys_Information,
&_POSIX_Message_queue_Information,
&_POSIX_Message_queue_Information_fds,
&_POSIX_Mutex_Information,
@@ -104,11 +105,45 @@ static void get_heap_info(Heap_Control *heap, Heap_Information_block *info)
memset(&info->Stats, 0, sizeof(info->Stats));
}
+static bool count_posix_key_value_pairs(
+ const RBTree_Node *node,
+ RBTree_Direction dir,
+ void *visitor_arg
+)
+{
+ uint32_t *count = visitor_arg;
+
+ (void) node;
+ (void) dir;
+
+ ++(*count);
+
+ return false;
+}
+
+static uint32_t get_active_posix_key_value_pairs(void)
+{
+ uint32_t count = 0;
+
+ _Thread_Disable_dispatch();
+ _RBTree_Iterate(
+ &_POSIX_Keys_Key_value_lookup_tree,
+ RBT_LEFT,
+ count_posix_key_value_pairs,
+ &count
+ );
+ _Thread_Enable_dispatch();
+
+ return count;
+}
+
void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot)
{
- uint32_t *active = &snapshot->rtems_api.active_barriers;
+ uint32_t *active = &snapshot->active_posix_keys;
size_t i;
+ memset(snapshot, 0, sizeof(*snapshot));
+
_RTEMS_Lock_allocator();
_Thread_Kill_zombies();
@@ -122,10 +157,7 @@ void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot)
_RTEMS_Unlock_allocator();
- #ifndef RTEMS_POSIX_API
- memset(&snapshot->posix_api, 0, sizeof(snapshot->posix_api));
- #endif
-
+ snapshot->active_posix_key_value_pairs = get_active_posix_key_value_pairs();
snapshot->open_files = open_files();
}