forked from Imagelibrary/rtems
Add POSIX key value pairs to resource snapshot
This commit is contained in:
@@ -118,7 +118,6 @@ typedef struct {
|
||||
typedef struct {
|
||||
uint32_t active_barriers;
|
||||
uint32_t active_condition_variables;
|
||||
uint32_t active_keys;
|
||||
uint32_t active_message_queues;
|
||||
uint32_t active_message_queue_descriptors;
|
||||
uint32_t active_mutexes;
|
||||
@@ -132,6 +131,8 @@ typedef struct {
|
||||
typedef struct {
|
||||
Heap_Information_block workspace_info;
|
||||
Heap_Information_block heap_info;
|
||||
uint32_t active_posix_key_value_pairs;
|
||||
uint32_t active_posix_keys;
|
||||
rtems_resource_rtems_api rtems_api;
|
||||
rtems_resource_posix_api posix_api;
|
||||
int open_files;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014. On-Line Applications Research Corporation (OAR).
|
||||
* Copyright (c) 2011-2012 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2011-2014 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
@@ -45,6 +45,11 @@ const char rtems_test_name[] = "PSXCONFIG 1";
|
||||
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEYS 23
|
||||
#ifdef CONFIGURE_MAXIMUM_POSIX_KEYS
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS CONFIGURE_MAXIMUM_POSIX_KEYS
|
||||
#endif
|
||||
|
||||
#define CONFIGURE_MAXIMUM_BARRIERS 2
|
||||
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 7
|
||||
#define CONFIGURE_MAXIMUM_PARTITIONS 37
|
||||
@@ -60,7 +65,6 @@ const char rtems_test_name[] = "PSXCONFIG 1";
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_BARRIERS 31
|
||||
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 29
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEYS 23
|
||||
#define POSIX_MQ_COUNT 5
|
||||
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 19
|
||||
#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 7
|
||||
@@ -262,6 +266,7 @@ static rtems_task Init(rtems_task_argument argument)
|
||||
rtems_extensions_table table;
|
||||
rtems_resource_snapshot snapshot;
|
||||
int i = 0;
|
||||
pthread_key_t key;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
@@ -299,6 +304,27 @@ static rtems_task Init(rtems_task_argument argument)
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIGURE_MAXIMUM_POSIX_KEYS
|
||||
for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_KEYS; ++i) {
|
||||
eno = pthread_key_create(&key, posix_key_dtor);
|
||||
rtems_test_assert(eno == 0);
|
||||
|
||||
eno = pthread_setspecific(key, (void *) (i + 1));
|
||||
rtems_test_assert(eno == 0);
|
||||
}
|
||||
eno = pthread_key_create(&key, posix_key_dtor);
|
||||
rtems_test_assert(eno == EAGAIN);
|
||||
rtems_resource_snapshot_take(&snapshot);
|
||||
rtems_test_assert(
|
||||
snapshot.active_posix_keys == CONFIGURE_POSIX_KEYS
|
||||
);
|
||||
rtems_test_assert(
|
||||
snapshot.active_posix_key_value_pairs == CONFIGURE_MAXIMUM_POSIX_KEYS
|
||||
);
|
||||
#else
|
||||
(void) key;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIGURE_MAXIMUM_BARRIERS
|
||||
for (i = 0; i < CONFIGURE_MAXIMUM_BARRIERS; ++i) {
|
||||
sc = rtems_barrier_create(name, RTEMS_DEFAULT_ATTRIBUTES, 1, &id);
|
||||
@@ -455,18 +481,6 @@ static rtems_task Init(rtems_task_argument argument)
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIGURE_MAXIMUM_POSIX_KEYS
|
||||
for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_KEYS; ++i) {
|
||||
pthread_key_t key;
|
||||
eno = pthread_key_create(&key, posix_key_dtor);
|
||||
rtems_test_assert(eno == 0);
|
||||
}
|
||||
rtems_resource_snapshot_take(&snapshot);
|
||||
rtems_test_assert(
|
||||
snapshot.posix_api.active_keys == CONFIGURE_POSIX_KEYS
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef POSIX_MQ_COUNT
|
||||
for (i = 0; i < POSIX_MQ_COUNT; ++i) {
|
||||
int oflag = O_RDWR | O_CREAT | O_EXCL;
|
||||
|
||||
Reference in New Issue
Block a user