summaryrefslogblamecommitdiffstats
path: root/cpukit/score/src/iterateoverthreads.c
blob: 89333522988df9a1b1a6eb96d1b74d550c0ebf89 (plain) (tree)
1
2
3
4
5
6
7
8
9

         
  




                                    
                            



                                                           
                                         

   



                   
                               
                                   


                                                                     

                                 

                                   
 


                 
                                                                        



                                                         
 
                                                               




                                                                   
 

                        
 
                             

     
 
 
/**
 *  @file
 *
 *  @brief Iterates Over All Threads
 *  @ingroup ScoreThread
 */

/*
 *  COPYRIGHT (c) 1989-2010.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <rtems/score/thread.h>
#include <rtems/score/objectimpl.h>

void rtems_iterate_over_all_threads(rtems_per_thread_routine routine)
{
  uint32_t             i;
  uint32_t             api_index;
  Thread_Control      *the_thread;
  Objects_Information *information;

  if ( !routine )
    return;

  for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
    #if !defined(RTEMS_POSIX_API) || defined(RTEMS_DEBUG)
      if ( !_Objects_Information_table[ api_index ] )
        continue;
    #endif

    information = _Objects_Information_table[ api_index ][ 1 ];
    if ( !information )
      continue;

    for ( i=1 ; i <= information->maximum ; i++ ) {
      the_thread = (Thread_Control *)information->local_table[ i ];

      if ( !the_thread )
	continue;

      (*routine)(the_thread);
    }
  }

}