source: rtems/cpukit/score/src/threaditerate.c @ 3899bc1a

Last change on this file since 3899bc1a was 3899bc1a, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 24, 2018 at 10:51:28 AM

score: Optimize object lookup

Use the maximum ID for the ID to object translation. Using the maximum
ID gets rid of an additional load from the object information in
_Objects_Get(). In addition, object lookups fail for every ID in case
the object information is cleared to zero. This makes it a bit more
robust during system startup (see new tests in spconfig02).

The local table no longer needs a NULL pointer entry at array index
zero. Adjust all the object iteration loops accordingly.

Remove Objects_Information::minimum_id since it contains only redundant
information. Add _Objects_Get_minimum_id() to get the minimum ID.

Update #3621.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/score/threadimpl.h>
20
21void _Thread_Iterate(
22  Thread_Visitor  visitor,
23  void           *arg
24)
25{
26  int api_index;
27
28  for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; ++api_index ) {
29    const Objects_Information *information;
30    Objects_Maximum            i;
31
32    if ( _Objects_Information_table[ api_index ] == NULL ) {
33      continue;
34    }
35
36    information = _Objects_Information_table[ api_index ][ 1 ];
37
38    if ( information == NULL ) {
39      continue;
40    }
41
42    for ( i = 0 ; i < information->maximum ; ++i ) {
43      Thread_Control *the_thread;
44
45      the_thread = (Thread_Control *) information->local_table[ i ];
46
47      if ( the_thread != NULL ) {
48        bool done;
49
50        done = (* visitor )( the_thread, arg );
51
52        if ( done ) {
53          return;
54        }
55      }
56    }
57  }
58}
Note: See TracBrowser for help on using the repository browser.