Exemple #1
0
static rtems_task Init(rtems_task_argument ignored)
{
    Freechain_Control fc;
    test_node *node;

    TEST_BEGIN();

    _Freechain_Initialize(&fc, NULL, 0, sizeof(test_node));
    rtems_test_assert(_Chain_Is_empty(&fc.Free));

    _Freechain_Initialize(&fc, malloc, 1, SIZE_MAX);
    rtems_test_assert(_Chain_Is_empty(&fc.Free));

    rtems_test_assert(_Freechain_Get(&fc, NULL, 0, sizeof(test_node)) == NULL);

    rtems_test_assert(_Freechain_Get(&fc, malloc, 1, SIZE_MAX) == NULL);

    /* check whether freechain put and get works correctly*/

    _Freechain_Put(&fc, NULL);

    puts( "INIT - Get node from freechain - OK" );
    node = _Freechain_Get(&fc, malloc, 1, sizeof(test_node));
    node->x = 1;

    puts( "INIT - Put node back to freechain - OK" );
    _Freechain_Put(&fc, node);

    puts( "INIT - Verify freechain node put and get - OK" );
    node = _Freechain_Get(&fc, NULL, 0, sizeof(test_node));
    rtems_test_assert(node->x == 1);

    TEST_END();
    rtems_test_exit(0);
}
Exemple #2
0
void _Thread_Initialize_information(
  Thread_Information  *information,
  Objects_APIs         the_api,
  uint16_t             the_class,
  uint32_t             maximum,
  bool                 is_string,
  uint32_t             maximum_name_length
)
{
  _Objects_Initialize_information(
    &information->Objects,
    the_api,
    the_class,
    maximum,
    _Thread_Control_size,
    is_string,
    maximum_name_length,
    NULL
  );

  _Freechain_Initialize(
    &information->Free_thread_queue_heads,
    _Workspace_Allocate_or_fatal_error,
    _Objects_Maximum_per_allocation( maximum ),
    THREAD_QUEUE_HEADS_SIZE( _Scheduler_Count )
  );
}
Exemple #3
0
void _Thread_Initialize_information(
  Thread_Information  *information,
  Objects_APIs         the_api,
  uint16_t             the_class,
  uint32_t             maximum,
  bool                 is_string,
  uint32_t             maximum_name_length
#if defined(RTEMS_MULTIPROCESSING)
  ,
  bool                 supports_global
#endif
)
{
  _Objects_Initialize_information(
    &information->Objects,
    the_api,
    the_class,
    maximum,
    _Thread_Control_size,
    is_string,
    maximum_name_length
    #if defined(RTEMS_MULTIPROCESSING)
      ,
      supports_global,
      NULL
    #endif
  );

  _Freechain_Initialize(
    &information->Free_thread_queue_heads,
    _Workspace_Allocate_or_fatal_error,
    _Objects_Maximum_per_allocation( maximum ),
    sizeof( Thread_queue_Heads )
  );
}
Exemple #4
0
static void _POSIX_Keys_Initialize_keypool( void )
{
  Freechain_Control *keypool = &_POSIX_Keys_Keypool;
  size_t initial_count = _POSIX_Keys_Get_initial_keypool_size();

  _Freechain_Initialize( keypool, _POSIX_Keys_Keypool_extend );

  if ( initial_count > 0 ) {
    size_t size = initial_count * sizeof( POSIX_Keys_Key_value_pair );
    POSIX_Keys_Key_value_pair *nodes =
      _Workspace_Allocate_or_fatal_error( size );

    _Chain_Initialize(
      &keypool->Freechain,
      nodes,
      initial_count,
      sizeof( *nodes )
    );
  }
}