Changeset 7bdb765 in rtems


Ignore:
Timestamp:
Dec 12, 2014, 7:46:30 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
26e04e2f
Parents:
172e953
git-author:
Sebastian Huber <sebastian.huber@…> (12/12/14 07:46:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/12/14 12:16:28)
Message:

Add POSIX key value pairs to resource snapshot

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/libcsupport.h

    r172e953 r7bdb765  
    119119  uint32_t active_barriers;
    120120  uint32_t active_condition_variables;
    121   uint32_t active_keys;
    122121  uint32_t active_message_queues;
    123122  uint32_t active_message_queue_descriptors;
     
    133132  Heap_Information_block workspace_info;
    134133  Heap_Information_block heap_info;
     134  uint32_t active_posix_key_value_pairs;
     135  uint32_t active_posix_keys;
    135136  rtems_resource_rtems_api rtems_api;
    136137  rtems_resource_posix_api posix_api;
  • cpukit/libcsupport/src/resource_snapshot.c

    r172e953 r7bdb765  
    11/*
    2  * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2012-2014 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
    5  *  Obere Lagerstr. 30
     5 *  Dornierstr. 4
    66 *  82178 Puchheim
    77 *  Germany
     
    2323#include <rtems/libio_.h>
    2424#include <rtems/malloc.h>
     25#include <rtems/score/rbtreeimpl.h>
    2526#include <rtems/score/protectedheap.h>
    2627#include <rtems/score/threadimpl.h>
    2728#include <rtems/score/wkspace.h>
    2829
    29 #include <rtems/extensionimpl.h>
     30#include <rtems/posix/keyimpl.h>
    3031
    3132#include <rtems/rtems/barrierimpl.h>
     33#include <rtems/extensionimpl.h>
    3234#include <rtems/rtems/dpmemimpl.h>
    3335#include <rtems/rtems/messageimpl.h>
     
    4446  #include <rtems/posix/mqueueimpl.h>
    4547  #include <rtems/posix/muteximpl.h>
    46   #include <rtems/posix/keyimpl.h>
    4748  #include <rtems/posix/psignal.h>
    4849  #include <rtems/posix/pthreadimpl.h>
     
    5354#endif
    5455
    55 static const Objects_Information *objects_info_table[] = {
     56static const Objects_Information *const objects_info_table[] = {
     57  &_POSIX_Keys_Information,
    5658  &_Barrier_Information,
    5759  &_Extension_Information,
     
    6870    &_POSIX_Barrier_Information,
    6971    &_POSIX_Condition_variables_Information,
    70     &_POSIX_Keys_Information,
    7172    &_POSIX_Message_queue_Information,
    7273    &_POSIX_Message_queue_Information_fds,
     
    105106}
    106107
     108static bool count_posix_key_value_pairs(
     109  const RBTree_Node *node,
     110  RBTree_Direction dir,
     111  void *visitor_arg
     112)
     113{
     114  uint32_t *count = visitor_arg;
     115
     116  (void) node;
     117  (void) dir;
     118
     119  ++(*count);
     120
     121  return false;
     122}
     123
     124static uint32_t get_active_posix_key_value_pairs(void)
     125{
     126  uint32_t count = 0;
     127
     128  _Thread_Disable_dispatch();
     129  _RBTree_Iterate(
     130    &_POSIX_Keys_Key_value_lookup_tree,
     131    RBT_LEFT,
     132    count_posix_key_value_pairs,
     133    &count
     134  );
     135  _Thread_Enable_dispatch();
     136
     137  return count;
     138}
     139
    107140void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot)
    108141{
    109   uint32_t *active = &snapshot->rtems_api.active_barriers;
     142  uint32_t *active = &snapshot->active_posix_keys;
    110143  size_t i;
     144
     145  memset(snapshot, 0, sizeof(*snapshot));
    111146
    112147  _RTEMS_Lock_allocator();
     
    123158  _RTEMS_Unlock_allocator();
    124159
    125   #ifndef RTEMS_POSIX_API
    126     memset(&snapshot->posix_api, 0, sizeof(snapshot->posix_api));
    127   #endif
    128 
     160  snapshot->active_posix_key_value_pairs = get_active_posix_key_value_pairs();
    129161  snapshot->open_files = open_files();
    130162}
  • testsuites/psxtests/psxconfig01/init.c

    r172e953 r7bdb765  
    99/*
    1010 * Copyright (c) 2014. On-Line Applications Research Corporation (OAR).
    11  * Copyright (c) 2011-2012 embedded brains GmbH.  All rights reserved.
     11 * Copyright (c) 2011-2014 embedded brains GmbH.  All rights reserved.
    1212 *
    1313 *  embedded brains GmbH
    14  *  Obere Lagerstr. 30
     14 *  Dornierstr. 4
    1515 *  82178 Puchheim
    1616 *  Germany
     
    4646#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
    4747
     48#define CONFIGURE_MAXIMUM_POSIX_KEYS 23
     49#ifdef CONFIGURE_MAXIMUM_POSIX_KEYS
     50  #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS CONFIGURE_MAXIMUM_POSIX_KEYS
     51#endif
     52
    4853#define CONFIGURE_MAXIMUM_BARRIERS 2
    4954#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 7
     
    6166#define CONFIGURE_MAXIMUM_POSIX_BARRIERS 31
    6267#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 29
    63 #define CONFIGURE_MAXIMUM_POSIX_KEYS 23
    6468#define POSIX_MQ_COUNT 5
    6569#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 19
     
    263267  rtems_resource_snapshot snapshot;
    264268  int i = 0;
     269  pthread_key_t key;
    265270
    266271  TEST_BEGIN();
     
    298303    snapshot.rtems_api.active_extensions == CONFIGURE_MAXIMUM_USER_EXTENSIONS
    299304  );
     305#endif
     306
     307#ifdef CONFIGURE_MAXIMUM_POSIX_KEYS
     308  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_KEYS; ++i) {
     309    eno = pthread_key_create(&key, posix_key_dtor);
     310    rtems_test_assert(eno == 0);
     311
     312    eno = pthread_setspecific(key, (void *) (i + 1));
     313    rtems_test_assert(eno == 0);
     314  }
     315  eno = pthread_key_create(&key, posix_key_dtor);
     316  rtems_test_assert(eno == EAGAIN);
     317  rtems_resource_snapshot_take(&snapshot);
     318  rtems_test_assert(
     319    snapshot.active_posix_keys == CONFIGURE_POSIX_KEYS
     320  );
     321  rtems_test_assert(
     322    snapshot.active_posix_key_value_pairs == CONFIGURE_MAXIMUM_POSIX_KEYS
     323  );
     324#else
     325  (void) key;
    300326#endif
    301327
     
    456482#endif
    457483
    458 #ifdef CONFIGURE_MAXIMUM_POSIX_KEYS
    459   for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_KEYS; ++i) {
    460     pthread_key_t key;
    461     eno = pthread_key_create(&key, posix_key_dtor);
    462     rtems_test_assert(eno == 0);
    463   }
    464   rtems_resource_snapshot_take(&snapshot);
    465   rtems_test_assert(
    466     snapshot.posix_api.active_keys == CONFIGURE_POSIX_KEYS
    467   );
    468 #endif
    469 
    470484#ifdef POSIX_MQ_COUNT
    471485  for (i = 0; i < POSIX_MQ_COUNT; ++i) {
Note: See TracChangeset for help on using the changeset viewer.