[RTEMS Project] #2423: rtems_iterate_over_all_threads lacks user callback private pointer pass through

RTEMS trac trac at rtems.org
Tue Sep 22 20:02:27 UTC 2015


#2423: rtems_iterate_over_all_threads lacks user callback private pointer pass
through
-------------------------------------------------+-------------------------
 Reporter:  johill                               |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  4.11.1
Component:  General                              |     Version:  4.10
 Severity:  normal                               |  Resolution:
 Keywords:  rtems_iterate_over_all_threads       |
  callback private                               |
-------------------------------------------------+-------------------------

Comment (by johill):

 PPS: In thread.h and iterateoverthreads.c one could create some code like
 this. A possible implementation.

 /**  This defines the type for a method which operates on a single thread.
  */
 typedef void (*rtems_per_thread_routine)( Thread_Control * );
 typedef void (*rtems_per_task_function)( Thread_Control *,
                                             void * const pUserPrivate );

 /**
  *  This routine iterates over all threads regardless of API and
  *  invokes the specified routine.
  */
 void rtems_iterate_over_all_threads(
   rtems_per_thread_routine routine
 );

 void rtems_thread_per_each_callback(rtems_per_task_function pFunction,
                                 void * const pUserPrivate );



 void rtems_thread_per_each_callback(rtems_per_task_function pFunction,
                                 void * const pUserPrivate )
 {
   uint32_t             i;
   uint32_t             api_index;
   Thread_Control      *the_thread;
   Objects_Information *information;

   if ( !pFunction )
     return;

   for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
     if ( !_Objects_Information_table[ api_index ] )
       continue;

     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;

       (*pFunction)(the_thread,pUserPrivate);
     }
   }

 }

--
Ticket URL: <http://devel.rtems.org/ticket/2423#comment:2>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list