source: rtems/cpukit/score/include/rtems/score/schedulerimpl.h @ d37adfe5

Last change on this file since d37adfe5 was d37adfe5, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 3, 2016 at 6:02:03 AM

score: Fix CPU time used by executing threads

The CPU time used of a thread was previously maintained per-processor
mostly during _Thread_Dispatch(). However, on SMP configurations the
actual processor of a thread is difficult to figure out since thread
dispatching is a highly asynchronous process (e.g. via inter-processor
interrupts). Only the intended processor of a thread is known to the
scheduler easily. Do the CPU usage accounting during thread heir
updates in the context of the scheduler operations. Provide the
function _Thread_Get_CPU_time_used() to get the CPU usage of a thread
using proper locks to get a consistent value.

Close #2627.

  • Property mode set to 100644
File size: 37.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with the Manipulation of the Scheduler
5 *
6 * This inline file contains all of the inlined routines associated with
7 * the manipulation of the scheduler.
8 */
9
10/*
11 *  Copyright (C) 2010 Gedare Bloom.
12 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
13 *  Copyright (c) 2014-2015 embedded brains GmbH
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#ifndef _RTEMS_SCORE_SCHEDULERIMPL_H
21#define _RTEMS_SCORE_SCHEDULERIMPL_H
22
23#include <rtems/score/scheduler.h>
24#include <rtems/score/cpusetimpl.h>
25#include <rtems/score/smpimpl.h>
26#include <rtems/score/threadimpl.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * @addtogroup ScoreScheduler
34 */
35/**@{**/
36
37/**
38 *  @brief Initializes the scheduler to the policy chosen by the user.
39 *
40 *  This routine initializes the scheduler to the policy chosen by the user
41 *  through confdefs, or to the priority scheduler with ready chains by
42 *  default.
43 */
44void _Scheduler_Handler_initialization( void );
45
46RTEMS_INLINE_ROUTINE Scheduler_Context *_Scheduler_Get_context(
47  const Scheduler_Control *scheduler
48)
49{
50  return scheduler->context;
51}
52
53RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get(
54  const Thread_Control *the_thread
55)
56{
57#if defined(RTEMS_SMP)
58  return the_thread->Scheduler.control;
59#else
60  (void) the_thread;
61
62  return &_Scheduler_Table[ 0 ];
63#endif
64}
65
66RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_own(
67  const Thread_Control *the_thread
68)
69{
70#if defined(RTEMS_SMP)
71  return the_thread->Scheduler.own_control;
72#else
73  (void) the_thread;
74
75  return &_Scheduler_Table[ 0 ];
76#endif
77}
78
79RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU_index(
80  uint32_t cpu_index
81)
82{
83#if defined(RTEMS_SMP)
84  return _Scheduler_Assignments[ cpu_index ].scheduler;
85#else
86  (void) cpu_index;
87
88  return &_Scheduler_Table[ 0 ];
89#endif
90}
91
92RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU(
93  const Per_CPU_Control *cpu
94)
95{
96  uint32_t cpu_index = _Per_CPU_Get_index( cpu );
97
98  return _Scheduler_Get_by_CPU_index( cpu_index );
99}
100
101RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Thread_get_own_node(
102  const Thread_Control *the_thread
103)
104{
105#if defined(RTEMS_SMP)
106  return the_thread->Scheduler.own_node;
107#else
108  return the_thread->Scheduler.node;
109#endif
110}
111
112#if defined(RTEMS_SMP)
113RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user(
114  const Scheduler_Node *node
115)
116{
117  return node->user;
118}
119#endif
120
121/**
122 * The preferred method to add a new scheduler is to define the jump table
123 * entries and add a case to the _Scheduler_Initialize routine.
124 *
125 * Generic scheduling implementations that rely on the ready queue only can
126 * be found in the _Scheduler_queue_XXX functions.
127 */
128
129/*
130 * Passing the Scheduler_Control* to these functions allows for multiple
131 * scheduler's to exist simultaneously, which could be useful on an SMP
132 * system.  Then remote Schedulers may be accessible.  How to protect such
133 * accesses remains an open problem.
134 */
135
136/**
137 * @brief General scheduling decision.
138 *
139 * This kernel routine implements the scheduling decision logic for
140 * the scheduler. It does NOT dispatch.
141 *
142 * @param[in] the_thread The thread which state changed previously.
143 */
144RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread )
145{
146  const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
147
148  ( *scheduler->Operations.schedule )( scheduler, the_thread );
149}
150
151#if defined(RTEMS_SMP)
152typedef struct {
153  Thread_Control *needs_help;
154  Thread_Control *next_needs_help;
155} Scheduler_Ask_for_help_context ;
156
157RTEMS_INLINE_ROUTINE bool _Scheduler_Ask_for_help_visitor(
158  Resource_Node *resource_node,
159  void          *arg
160)
161{
162  bool done;
163  Scheduler_Ask_for_help_context *help_context = arg;
164  Thread_Control *previous_needs_help = help_context->needs_help;
165  Thread_Control *next_needs_help;
166  Thread_Control *offers_help =
167    THREAD_RESOURCE_NODE_TO_THREAD( resource_node );
168  const Scheduler_Control *scheduler = _Scheduler_Get_own( offers_help );
169
170  next_needs_help = ( *scheduler->Operations.ask_for_help )(
171    scheduler,
172    offers_help,
173    previous_needs_help
174  );
175
176  done = next_needs_help != previous_needs_help;
177
178  if ( done ) {
179    help_context->next_needs_help = next_needs_help;
180  }
181
182  return done;
183}
184
185/**
186 * @brief Ask threads depending on resources owned by the thread for help.
187 *
188 * A thread is in need for help if it lost its assigned processor due to
189 * pre-emption by a higher priority thread or it was not possible to assign it
190 * a processor since its priority is to low on its current scheduler instance.
191 *
192 * The run-time of this function depends on the size of the resource tree of
193 * the thread needing help and other resource trees in case threads in need for
194 * help are produced during this operation.
195 *
196 * @param[in] needs_help The thread needing help.
197 */
198RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help(
199  Thread_Control *needs_help
200)
201{
202  do {
203    const Scheduler_Control *scheduler = _Scheduler_Get_own( needs_help );
204
205    needs_help = ( *scheduler->Operations.ask_for_help )(
206      scheduler,
207      needs_help,
208      needs_help
209    );
210
211    if ( needs_help != NULL ) {
212      Scheduler_Ask_for_help_context help_context = { needs_help, NULL };
213
214      _Resource_Iterate(
215        &needs_help->Resource_node,
216        _Scheduler_Ask_for_help_visitor,
217        &help_context
218      );
219
220      needs_help = help_context.next_needs_help;
221    }
222  } while ( needs_help != NULL );
223}
224
225RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help_if_necessary(
226  Thread_Control *needs_help
227)
228{
229  if (
230    needs_help != NULL
231      && _Resource_Node_owns_resources( &needs_help->Resource_node )
232  ) {
233    Scheduler_Node *node = _Scheduler_Thread_get_own_node( needs_help );
234
235    if (
236      node->help_state != SCHEDULER_HELP_ACTIVE_RIVAL
237        || _Scheduler_Node_get_user( node ) != needs_help
238    ) {
239      _Scheduler_Ask_for_help( needs_help );
240    }
241  }
242}
243#endif
244
245/**
246 * @brief Scheduler yield with a particular thread.
247 *
248 * This routine is invoked when a thread wishes to voluntarily transfer control
249 * of the processor to another thread.
250 *
251 * @param[in] the_thread The yielding thread.
252 */
253RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread )
254{
255  const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
256#if defined(RTEMS_SMP)
257  Thread_Control *needs_help;
258
259  needs_help =
260#endif
261  ( *scheduler->Operations.yield )( scheduler, the_thread );
262
263#if defined(RTEMS_SMP)
264  _Scheduler_Ask_for_help_if_necessary( needs_help );
265#endif
266}
267
268/**
269 * @brief Blocks a thread with respect to the scheduler.
270 *
271 * This routine removes @a the_thread from the scheduling decision for
272 * the scheduler. The primary task is to remove the thread from the
273 * ready queue.  It performs any necessary schedulering operations
274 * including the selection of a new heir thread.
275 *
276 * @param[in] the_thread The thread.
277 */
278RTEMS_INLINE_ROUTINE void _Scheduler_Block( Thread_Control *the_thread )
279{
280  const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
281
282  ( *scheduler->Operations.block )( scheduler, the_thread );
283}
284
285/**
286 * @brief Unblocks a thread with respect to the scheduler.
287 *
288 * This routine adds @a the_thread to the scheduling decision for
289 * the scheduler.  The primary task is to add the thread to the
290 * ready queue per the schedulering policy and update any appropriate
291 * scheduling variables, for example the heir thread.
292 *
293 * @param[in] the_thread The thread.
294 */
295RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread )
296{
297  const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
298#if defined(RTEMS_SMP)
299  Thread_Control *needs_help;
300
301  needs_help =
302#endif
303  ( *scheduler->Operations.unblock )( scheduler, the_thread );
304
305#if defined(RTEMS_SMP)
306  _Scheduler_Ask_for_help_if_necessary( needs_help );
307#endif
308}
309
310/**
311 * @brief Propagates a priority change of a thread to the scheduler.
312 *
313 * The caller must ensure that the thread is in the ready state.  The caller
314 * must ensure that the priority value actually changed and is not equal to the
315 * current priority value.
316 *
317 * The operation must update the heir and thread dispatch necessary variables
318 * in case the set of scheduled threads changes.
319 *
320 * @param[in] the_thread The thread changing its priority.
321 * @param[in] new_priority The new thread priority.
322 * @param[in] prepend_it In case this is true, then enqueue the thread as the
323 * first of its priority group, otherwise enqueue the thread as the last of its
324 * priority group.
325 */
326RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority(
327  Thread_Control          *the_thread,
328  Priority_Control         new_priority,
329  bool                     prepend_it
330)
331{
332  const Scheduler_Control *scheduler = _Scheduler_Get_own( the_thread );
333#if defined(RTEMS_SMP)
334  Thread_Control *needs_help;
335
336  needs_help =
337#endif
338  ( *scheduler->Operations.change_priority )(
339    scheduler,
340    the_thread,
341    new_priority,
342    prepend_it
343  );
344
345#if defined(RTEMS_SMP)
346  _Scheduler_Ask_for_help_if_necessary( needs_help );
347#endif
348}
349
350/**
351 * @brief Initializes a scheduler node.
352 *
353 * The scheduler node contains arbitrary data on function entry.  The caller
354 * must ensure that _Scheduler_Node_destroy() will be called after a
355 * _Scheduler_Node_initialize() before the memory of the scheduler node is
356 * destroyed.
357 *
358 * @param[in] scheduler The scheduler instance.
359 * @param[in] the_thread The thread containing the scheduler node.
360 */
361RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize(
362  const Scheduler_Control *scheduler,
363  Thread_Control          *the_thread
364)
365{
366  return ( *scheduler->Operations.node_initialize )( scheduler, the_thread );
367}
368
369/**
370 * @brief Destroys a scheduler node.
371 *
372 * The caller must ensure that _Scheduler_Node_destroy() will be called only
373 * after a corresponding _Scheduler_Node_initialize().
374 *
375 * @param[in] scheduler The scheduler instance.
376 * @param[in] the_thread The thread containing the scheduler node.
377 */
378RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy(
379  const Scheduler_Control *scheduler,
380  Thread_Control          *the_thread
381)
382{
383  ( *scheduler->Operations.node_destroy )( scheduler, the_thread );
384}
385
386/**
387 * @brief Updates the scheduler about a priority change of a not ready thread.
388 *
389 * @param[in] the_thread The thread.
390 * @param[in] new_priority The new priority of the thread.
391 */
392RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority(
393  Thread_Control   *the_thread,
394  Priority_Control  new_priority
395)
396{
397  const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
398
399  ( *scheduler->Operations.update_priority )(
400    scheduler,
401    the_thread,
402    new_priority
403  );
404}
405
406/**
407 * @brief Compares two priority values.
408 *
409 * @param[in] scheduler The scheduler instance.
410 * @param[in] p1 The first priority value.
411 * @param[in] p2 The second priority value.
412 *
413 * @retval negative The value @a p1 encodes a lower priority than @a p2 in the
414 * intuitive sense of priority.
415 * @retval 0 The priorities @a p1 and @a p2 are equal.
416 * @retval positive The value @a p1 encodes a higher priority than @a p2 in the
417 * intuitive sense of priority.
418 *
419 * @see _Scheduler_Is_priority_lower_than() and
420 * _Scheduler_Is_priority_higher_than().
421 */
422RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare(
423  const Scheduler_Control *scheduler,
424  Priority_Control         p1,
425  Priority_Control         p2
426)
427{
428  return ( *scheduler->Operations.priority_compare )( p1, p2 );
429}
430
431/**
432 * @brief Releases a job of a thread with respect to the scheduler.
433 *
434 * @param[in] the_thread The thread.
435 * @param[in] length The period length.
436 */
437RTEMS_INLINE_ROUTINE void _Scheduler_Release_job(
438  Thread_Control *the_thread,
439  uint32_t        length
440)
441{
442  const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
443
444  ( *scheduler->Operations.release_job )( scheduler, the_thread, length );
445}
446
447/**
448 * @brief Scheduler method invoked at each clock tick.
449 *
450 * This method is invoked at each clock tick to allow the scheduler
451 * implementation to perform any activities required.  For the
452 * scheduler which support standard RTEMS features, this includes
453 * time-slicing management.
454 */
455RTEMS_INLINE_ROUTINE void _Scheduler_Tick( const Per_CPU_Control *cpu )
456{
457  const Scheduler_Control *scheduler = _Scheduler_Get_by_CPU( cpu );
458  Thread_Control *executing = cpu->executing;
459
460  if ( scheduler != NULL && executing != NULL ) {
461    ( *scheduler->Operations.tick )( scheduler, executing );
462  }
463}
464
465/**
466 * @brief Starts the idle thread for a particular processor.
467 *
468 * @param[in] scheduler The scheduler instance.
469 * @param[in,out] the_thread The idle thread for the processor.
470 * @param[in,out] cpu The processor for the idle thread.
471 *
472 * @see _Thread_Create_idle().
473 */
474RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
475  const Scheduler_Control *scheduler,
476  Thread_Control          *the_thread,
477  Per_CPU_Control         *cpu
478)
479{
480  ( *scheduler->Operations.start_idle )( scheduler, the_thread, cpu );
481}
482
483#if defined(RTEMS_SMP)
484RTEMS_INLINE_ROUTINE const Scheduler_Assignment *_Scheduler_Get_assignment(
485  uint32_t cpu_index
486)
487{
488  return &_Scheduler_Assignments[ cpu_index ];
489}
490
491RTEMS_INLINE_ROUTINE bool _Scheduler_Is_mandatory_processor(
492  const Scheduler_Assignment *assignment
493)
494{
495  return (assignment->attributes & SCHEDULER_ASSIGN_PROCESSOR_MANDATORY) != 0;
496}
497
498RTEMS_INLINE_ROUTINE bool _Scheduler_Should_start_processor(
499  const Scheduler_Assignment *assignment
500)
501{
502  return assignment->scheduler != NULL;
503}
504#endif /* defined(RTEMS_SMP) */
505
506RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership(
507  const Scheduler_Control *scheduler,
508  uint32_t cpu_index
509)
510{
511#if defined(RTEMS_SMP)
512  const Scheduler_Assignment *assignment =
513    _Scheduler_Get_assignment( cpu_index );
514
515  return assignment->scheduler == scheduler;
516#else
517  (void) scheduler;
518  (void) cpu_index;
519
520  return true;
521#endif
522}
523
524RTEMS_INLINE_ROUTINE void _Scheduler_Set(
525  const Scheduler_Control *scheduler,
526  Thread_Control          *the_thread
527)
528{
529#if defined(RTEMS_SMP)
530  const Scheduler_Control *current_scheduler = _Scheduler_Get( the_thread );
531
532  if ( current_scheduler != scheduler ) {
533    _Thread_Set_state( the_thread, STATES_MIGRATING );
534    _Scheduler_Node_destroy( current_scheduler, the_thread );
535    the_thread->Scheduler.own_control = scheduler;
536    the_thread->Scheduler.control = scheduler;
537    _Scheduler_Node_initialize( scheduler, the_thread );
538    _Scheduler_Update_priority( the_thread, the_thread->current_priority );
539    _Thread_Clear_state( the_thread, STATES_MIGRATING );
540  }
541#else
542  (void) scheduler;
543#endif
544}
545
546#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
547
548RTEMS_INLINE_ROUTINE void _Scheduler_Get_processor_set(
549  const Scheduler_Control *scheduler,
550  size_t                   cpusetsize,
551  cpu_set_t               *cpuset
552)
553{
554  uint32_t cpu_count = _SMP_Get_processor_count();
555  uint32_t cpu_index;
556
557  CPU_ZERO_S( cpusetsize, cpuset );
558
559  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
560#if defined(RTEMS_SMP)
561    if ( _Scheduler_Has_processor_ownership( scheduler, cpu_index ) ) {
562      CPU_SET_S( (int) cpu_index, cpusetsize, cpuset );
563    }
564#else
565    (void) scheduler;
566
567    CPU_SET_S( (int) cpu_index, cpusetsize, cpuset );
568#endif
569  }
570}
571
572RTEMS_INLINE_ROUTINE bool _Scheduler_default_Get_affinity_body(
573  const Scheduler_Control *scheduler,
574  Thread_Control          *the_thread,
575  size_t                   cpusetsize,
576  cpu_set_t               *cpuset
577)
578{
579  (void) the_thread;
580
581  _Scheduler_Get_processor_set( scheduler, cpusetsize, cpuset );
582
583  return true;
584}
585
586bool _Scheduler_Get_affinity(
587  Thread_Control *the_thread,
588  size_t          cpusetsize,
589  cpu_set_t      *cpuset
590);
591
592RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body(
593  const Scheduler_Control *scheduler,
594  Thread_Control          *the_thread,
595  size_t                   cpusetsize,
596  const cpu_set_t         *cpuset
597)
598{
599  uint32_t cpu_count = _SMP_Get_processor_count();
600  uint32_t cpu_index;
601  bool     ok = true;
602
603  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
604#if defined(RTEMS_SMP)
605    const Scheduler_Control *scheduler_of_cpu =
606      _Scheduler_Get_by_CPU_index( cpu_index );
607
608    ok = ok
609      && ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
610        || ( !CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
611          && scheduler != scheduler_of_cpu ) );
612#else
613    (void) scheduler;
614
615    ok = ok && CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset );
616#endif
617  }
618
619  return ok;
620}
621
622bool _Scheduler_Set_affinity(
623  Thread_Control          *the_thread,
624  size_t                   cpusetsize,
625  const cpu_set_t         *cpuset
626);
627
628#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
629
630RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block(
631  const Scheduler_Control *scheduler,
632  Thread_Control          *the_thread,
633  void                  ( *extract )(
634                             const Scheduler_Control *,
635                             Thread_Control * ),
636  void                  ( *schedule )(
637                             const Scheduler_Control *,
638                             Thread_Control *,
639                             bool )
640)
641{
642  ( *extract )( scheduler, the_thread );
643
644  /* TODO: flash critical section? */
645
646  if ( _Thread_Is_executing( the_thread ) || _Thread_Is_heir( the_thread ) ) {
647    ( *schedule )( scheduler, the_thread, true );
648  }
649}
650
651/**
652 * @brief Returns true if @a p1 encodes a lower priority than @a p2 in the
653 * intuitive sense of priority.
654 */
655RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_lower_than(
656  const Scheduler_Control *scheduler,
657  Priority_Control         p1,
658  Priority_Control         p2
659)
660{
661  return _Scheduler_Priority_compare( scheduler, p1,  p2 ) < 0;
662}
663
664/**
665 * @brief Returns true if @a p1 encodes a higher priority than @a p2 in the
666 * intuitive sense of priority.
667 */
668RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_higher_than(
669  const Scheduler_Control *scheduler,
670  Priority_Control         p1,
671  Priority_Control         p2
672)
673{
674  return _Scheduler_Priority_compare( scheduler, p1,  p2 ) > 0;
675}
676
677RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count(
678  const Scheduler_Control *scheduler
679)
680{
681#if defined(RTEMS_SMP)
682  return _Scheduler_Get_context( scheduler )->processor_count;
683#else
684  (void) scheduler;
685
686  return 1;
687#endif
688}
689
690RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index )
691{
692  return _Objects_Build_id(
693    OBJECTS_FAKE_OBJECTS_API,
694    OBJECTS_FAKE_OBJECTS_SCHEDULERS,
695    _Objects_Local_node,
696    scheduler_index + 1
697  );
698}
699
700RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id( Objects_Id id )
701{
702  uint32_t minimum_id = _Scheduler_Build_id( 0 );
703
704  return id - minimum_id;
705}
706
707RTEMS_INLINE_ROUTINE bool _Scheduler_Get_by_id(
708  Objects_Id                id,
709  const Scheduler_Control **scheduler_p
710)
711{
712  uint32_t index = _Scheduler_Get_index_by_id( id );
713  const Scheduler_Control *scheduler = &_Scheduler_Table[ index ];
714
715  *scheduler_p = scheduler;
716
717  return index < _Scheduler_Count
718    && _Scheduler_Get_processor_count( scheduler ) > 0;
719}
720
721RTEMS_INLINE_ROUTINE bool _Scheduler_Is_id_valid( Objects_Id id )
722{
723  const Scheduler_Control *scheduler;
724  bool ok = _Scheduler_Get_by_id( id, &scheduler );
725
726  (void) scheduler;
727
728  return ok;
729}
730
731RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index(
732  const Scheduler_Control *scheduler
733)
734{
735  return (uint32_t) (scheduler - &_Scheduler_Table[ 0 ]);
736}
737
738RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Thread_get_node(
739  const Thread_Control *the_thread
740)
741{
742  return the_thread->Scheduler.node;
743}
744
745RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
746  Scheduler_Node *node,
747  Thread_Control *the_thread
748)
749{
750#if defined(RTEMS_SMP)
751  node->user = the_thread;
752  node->help_state = SCHEDULER_HELP_YOURSELF;
753  node->owner = the_thread;
754  node->idle = NULL;
755  node->accepts_help = the_thread;
756#else
757  (void) node;
758  (void) the_thread;
759#endif
760}
761
762#if defined(RTEMS_SMP)
763/**
764 * @brief Gets an idle thread from the scheduler instance.
765 *
766 * @param[in] context The scheduler instance context.
767 *
768 * @retval idle An idle thread for use.  This function must always return an
769 * idle thread.  If none is available, then this is a fatal error.
770 */
771typedef Thread_Control *( *Scheduler_Get_idle_thread )(
772  Scheduler_Context *context
773);
774
775/**
776 * @brief Releases an idle thread to the scheduler instance for reuse.
777 *
778 * @param[in] context The scheduler instance context.
779 * @param[in] idle The idle thread to release
780 */
781typedef void ( *Scheduler_Release_idle_thread )(
782  Scheduler_Context *context,
783  Thread_Control    *idle
784);
785
786RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner(
787  const Scheduler_Node *node
788)
789{
790  return node->owner;
791}
792
793RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle(
794  const Scheduler_Node *node
795)
796{
797  return node->idle;
798}
799
800RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user(
801  Scheduler_Node *node,
802  Thread_Control *user
803)
804{
805  node->user = user;
806}
807
808RTEMS_INLINE_ROUTINE void _Scheduler_Thread_set_node(
809  Thread_Control *the_thread,
810  Scheduler_Node *node
811)
812{
813  the_thread->Scheduler.node = node;
814}
815
816RTEMS_INLINE_ROUTINE void _Scheduler_Thread_set_scheduler_and_node(
817  Thread_Control       *the_thread,
818  Scheduler_Node       *node,
819  const Thread_Control *previous_user_of_node
820)
821{
822  const Scheduler_Control *scheduler =
823    _Scheduler_Get_own( previous_user_of_node );
824
825  the_thread->Scheduler.control = scheduler;
826  _Scheduler_Thread_set_node( the_thread, node );
827}
828
829extern const bool _Scheduler_Thread_state_valid_state_changes[ 3 ][ 3 ];
830
831RTEMS_INLINE_ROUTINE void _Scheduler_Thread_change_state(
832  Thread_Control         *the_thread,
833  Thread_Scheduler_state  new_state
834)
835{
836  _Assert(
837    _Scheduler_Thread_state_valid_state_changes
838      [ the_thread->Scheduler.state ][ new_state ]
839  );
840
841  the_thread->Scheduler.state = new_state;
842}
843
844/**
845 * @brief Changes the scheduler help state of a thread.
846 *
847 * @param[in] the_thread The thread.
848 * @param[in] new_help_state The new help state.
849 *
850 * @return The previous help state.
851 */
852RTEMS_INLINE_ROUTINE Scheduler_Help_state _Scheduler_Thread_change_help_state(
853  Thread_Control       *the_thread,
854  Scheduler_Help_state  new_help_state
855)
856{
857  Scheduler_Node *node = _Scheduler_Thread_get_own_node( the_thread );
858  Scheduler_Help_state previous_help_state = node->help_state;
859
860  node->help_state = new_help_state;
861
862  return previous_help_state;
863}
864
865/**
866 * @brief Changes the resource tree root of a thread.
867 *
868 * For each node of the resource sub-tree specified by the top thread the
869 * scheduler asks for help.  So the root thread gains access to all scheduler
870 * nodes corresponding to the resource sub-tree.  In case a thread previously
871 * granted help is displaced by this operation, then the scheduler asks for
872 * help using its remaining resource tree.
873 *
874 * The run-time of this function depends on the size of the resource sub-tree
875 * and other resource trees in case threads in need for help are produced
876 * during this operation.
877 *
878 * @param[in] top The thread specifying the resource sub-tree top.
879 * @param[in] root The thread specifying the new resource sub-tree root.
880 */
881void _Scheduler_Thread_change_resource_root(
882  Thread_Control *top,
883  Thread_Control *root
884);
885
886RTEMS_INLINE_ROUTINE void _Scheduler_Set_idle_thread(
887  Scheduler_Node *node,
888  Thread_Control *idle
889)
890{
891  _Assert(
892    node->help_state == SCHEDULER_HELP_ACTIVE_OWNER
893      || node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL
894  );
895  _Assert( _Scheduler_Node_get_idle( node ) == NULL );
896  _Assert(
897    _Scheduler_Node_get_owner( node ) == _Scheduler_Node_get_user( node )
898  );
899
900  _Scheduler_Thread_set_node( idle, node );
901
902  _Scheduler_Node_set_user( node, idle );
903  node->idle = idle;
904}
905
906/**
907 * @brief Use an idle thread for this scheduler node.
908 *
909 * A thread in the SCHEDULER_HELP_ACTIVE_OWNER or SCHEDULER_HELP_ACTIVE_RIVAL
910 * helping state may use an idle thread for the scheduler node owned by itself
911 * in case it executes currently using another scheduler node or in case it is
912 * in a blocking state.
913 *
914 * @param[in] context The scheduler instance context.
915 * @param[in] node The node which wants to use the idle thread.
916 * @param[in] get_idle_thread Function to get an idle thread.
917 */
918RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Use_idle_thread(
919  Scheduler_Context         *context,
920  Scheduler_Node            *node,
921  Scheduler_Get_idle_thread  get_idle_thread
922)
923{
924  Thread_Control *idle = ( *get_idle_thread )( context );
925
926  _Scheduler_Set_idle_thread( node, idle );
927
928  return idle;
929}
930
931typedef enum {
932  SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE,
933  SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE,
934  SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK
935} Scheduler_Try_to_schedule_action;
936
937/**
938 * @brief Try to schedule this scheduler node.
939 *
940 * @param[in] context The scheduler instance context.
941 * @param[in] node The node which wants to get scheduled.
942 * @param[in] idle A potential idle thread used by a potential victim node.
943 * @param[in] get_idle_thread Function to get an idle thread.
944 *
945 * @retval true This node can be scheduled.
946 * @retval false Otherwise.
947 */
948RTEMS_INLINE_ROUTINE Scheduler_Try_to_schedule_action
949_Scheduler_Try_to_schedule_node(
950  Scheduler_Context         *context,
951  Scheduler_Node            *node,
952  Thread_Control            *idle,
953  Scheduler_Get_idle_thread  get_idle_thread
954)
955{
956  Scheduler_Try_to_schedule_action action;
957  Thread_Control *owner;
958  Thread_Control *user;
959
960  action = SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE;
961
962  if ( node->help_state == SCHEDULER_HELP_YOURSELF ) {
963    return action;
964  }
965
966  owner = _Scheduler_Node_get_owner( node );
967  user = _Scheduler_Node_get_user( node );
968
969  if ( node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL) {
970    if ( user->Scheduler.state == THREAD_SCHEDULER_READY ) {
971      _Scheduler_Thread_set_scheduler_and_node( user, node, owner );
972    } else if ( owner->Scheduler.state == THREAD_SCHEDULER_BLOCKED ) {
973      if ( idle != NULL ) {
974        action = SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE;
975      } else {
976        _Scheduler_Use_idle_thread( context, node, get_idle_thread );
977      }
978    } else {
979      _Scheduler_Node_set_user( node, owner );
980    }
981  } else if ( node->help_state == SCHEDULER_HELP_ACTIVE_OWNER ) {
982    if ( user->Scheduler.state == THREAD_SCHEDULER_READY ) {
983      _Scheduler_Thread_set_scheduler_and_node( user, node, owner );
984    } else if ( idle != NULL ) {
985      action = SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE;
986    } else {
987      _Scheduler_Use_idle_thread( context, node, get_idle_thread );
988    }
989  } else {
990    _Assert( node->help_state == SCHEDULER_HELP_PASSIVE );
991
992    if ( user->Scheduler.state == THREAD_SCHEDULER_READY ) {
993      _Scheduler_Thread_set_scheduler_and_node( user, node, owner );
994    } else {
995      action = SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK;
996    }
997  }
998
999  return action;
1000}
1001
1002/**
1003 * @brief Release an idle thread using this scheduler node.
1004 *
1005 * @param[in] context The scheduler instance context.
1006 * @param[in] node The node which may have an idle thread as user.
1007 * @param[in] release_idle_thread Function to release an idle thread.
1008 *
1009 * @retval idle The idle thread which used this node.
1010 * @retval NULL This node had no idle thread as an user.
1011 */
1012RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Release_idle_thread(
1013  Scheduler_Context             *context,
1014  Scheduler_Node                *node,
1015  Scheduler_Release_idle_thread  release_idle_thread
1016)
1017{
1018  Thread_Control *idle = _Scheduler_Node_get_idle( node );
1019
1020  if ( idle != NULL ) {
1021    Thread_Control *owner = _Scheduler_Node_get_owner( node );
1022
1023    node->idle = NULL;
1024    _Scheduler_Node_set_user( node, owner );
1025    _Scheduler_Thread_change_state( idle, THREAD_SCHEDULER_READY );
1026    _Scheduler_Thread_set_node( idle, idle->Scheduler.own_node );
1027
1028    ( *release_idle_thread )( context, idle );
1029  }
1030
1031  return idle;
1032}
1033
1034RTEMS_INLINE_ROUTINE void _Scheduler_Exchange_idle_thread(
1035  Scheduler_Node *needs_idle,
1036  Scheduler_Node *uses_idle,
1037  Thread_Control *idle
1038)
1039{
1040  uses_idle->idle = NULL;
1041  _Scheduler_Node_set_user(
1042    uses_idle,
1043    _Scheduler_Node_get_owner( uses_idle )
1044  );
1045  _Scheduler_Set_idle_thread( needs_idle, idle );
1046}
1047
1048/**
1049 * @brief Block this scheduler node.
1050 *
1051 * @param[in] context The scheduler instance context.
1052 * @param[in] thread The thread which wants to get blocked referencing this
1053 *   node.  This is not necessarily the user of this node in case the node
1054 *   participates in the scheduler helping protocol.
1055 * @param[in] node The node which wants to get blocked.
1056 * @param[in] is_scheduled This node is scheduled.
1057 * @param[in] get_idle_thread Function to get an idle thread.
1058 *
1059 * @retval true Continue with the blocking operation.
1060 * @retval false Otherwise.
1061 */
1062RTEMS_INLINE_ROUTINE bool _Scheduler_Block_node(
1063  Scheduler_Context         *context,
1064  Thread_Control            *thread,
1065  Scheduler_Node            *node,
1066  bool                       is_scheduled,
1067  Scheduler_Get_idle_thread  get_idle_thread
1068)
1069{
1070  Thread_Control *old_user;
1071  Thread_Control *new_user;
1072
1073  _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED );
1074
1075  if ( node->help_state == SCHEDULER_HELP_YOURSELF ) {
1076    _Assert( thread == _Scheduler_Node_get_user( node ) );
1077
1078    return true;
1079  }
1080
1081  new_user = NULL;
1082
1083  if ( node->help_state == SCHEDULER_HELP_ACTIVE_OWNER ) {
1084    if ( is_scheduled ) {
1085      _Assert( thread == _Scheduler_Node_get_user( node ) );
1086      old_user = thread;
1087      new_user = _Scheduler_Use_idle_thread( context, node, get_idle_thread );
1088    }
1089  } else if ( node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL ) {
1090    if ( is_scheduled ) {
1091      old_user = _Scheduler_Node_get_user( node );
1092
1093      if ( thread == old_user ) {
1094        Thread_Control *owner = _Scheduler_Node_get_owner( node );
1095
1096        if (
1097          thread != owner
1098            && owner->Scheduler.state == THREAD_SCHEDULER_READY
1099        ) {
1100          new_user = owner;
1101          _Scheduler_Node_set_user( node, new_user );
1102        } else {
1103          new_user = _Scheduler_Use_idle_thread( context, node, get_idle_thread );
1104        }
1105      }
1106    }
1107  } else {
1108    /* Not implemented, this is part of the OMIP support path. */
1109    _Assert(0);
1110  }
1111
1112  if ( new_user != NULL ) {
1113    Per_CPU_Control *cpu = _Thread_Get_CPU( old_user );
1114
1115    _Scheduler_Thread_change_state( new_user, THREAD_SCHEDULER_SCHEDULED );
1116    _Thread_Set_CPU( new_user, cpu );
1117    _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, new_user );
1118  }
1119
1120  return false;
1121}
1122
1123/**
1124 * @brief Unblock this scheduler node.
1125 *
1126 * @param[in] context The scheduler instance context.
1127 * @param[in] the_thread The thread which wants to get unblocked.
1128 * @param[in] node The node which wants to get unblocked.
1129 * @param[in] is_scheduled This node is scheduled.
1130 * @param[in] release_idle_thread Function to release an idle thread.
1131 *
1132 * @retval true Continue with the unblocking operation.
1133 * @retval false Otherwise.
1134 */
1135RTEMS_INLINE_ROUTINE bool _Scheduler_Unblock_node(
1136  Scheduler_Context             *context,
1137  Thread_Control                *the_thread,
1138  Scheduler_Node                *node,
1139  bool                           is_scheduled,
1140  Scheduler_Release_idle_thread  release_idle_thread
1141)
1142{
1143  bool unblock;
1144
1145  if ( is_scheduled ) {
1146    Thread_Control *old_user = _Scheduler_Node_get_user( node );
1147    Per_CPU_Control *cpu = _Thread_Get_CPU( old_user );
1148    Thread_Control *idle = _Scheduler_Release_idle_thread(
1149      context,
1150      node,
1151      release_idle_thread
1152    );
1153    Thread_Control *owner = _Scheduler_Node_get_owner( node );
1154    Thread_Control *new_user;
1155
1156    if ( node->help_state == SCHEDULER_HELP_ACTIVE_OWNER ) {
1157      _Assert( idle != NULL );
1158      new_user = the_thread;
1159    } else if ( idle != NULL ) {
1160      _Assert( node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL );
1161      new_user = the_thread;
1162    } else if ( the_thread != owner ) {
1163      _Assert( node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL );
1164      _Assert( old_user != the_thread );
1165      _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_READY );
1166      new_user = the_thread;
1167      _Scheduler_Node_set_user( node, new_user );
1168    } else {
1169      _Assert( node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL );
1170      _Assert( old_user != the_thread );
1171      _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_READY );
1172      new_user = NULL;
1173    }
1174
1175    if ( new_user != NULL ) {
1176      _Scheduler_Thread_change_state( new_user, THREAD_SCHEDULER_SCHEDULED );
1177      _Thread_Set_CPU( new_user, cpu );
1178      _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, new_user );
1179    }
1180
1181    unblock = false;
1182  } else {
1183    _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_READY );
1184
1185    unblock = true;
1186  }
1187
1188  return unblock;
1189}
1190
1191/**
1192 * @brief Asks a ready scheduler node for help.
1193 *
1194 * @param[in] node The ready node offering help.
1195 * @param[in] needs_help The thread needing help.
1196 *
1197 * @retval needs_help The thread needing help.
1198 */
1199RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Ask_ready_node_for_help(
1200  Scheduler_Node *node,
1201  Thread_Control *needs_help
1202)
1203{
1204  _Scheduler_Node_set_user( node, needs_help );
1205
1206  return needs_help;
1207}
1208
1209/**
1210 * @brief Asks a scheduled scheduler node for help.
1211 *
1212 * @param[in] context The scheduler instance context.
1213 * @param[in] node The scheduled node offering help.
1214 * @param[in] offers_help The thread offering help.
1215 * @param[in] needs_help The thread needing help.
1216 * @param[in] previous_accepts_help The previous thread accepting help by this
1217 *   scheduler node.
1218 * @param[in] release_idle_thread Function to release an idle thread.
1219 *
1220 * @retval needs_help The previous thread accepting help by this scheduler node
1221 *   which was displaced by the thread needing help.
1222 * @retval NULL There are no more threads needing help.
1223 */
1224RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Ask_scheduled_node_for_help(
1225  Scheduler_Context             *context,
1226  Scheduler_Node                *node,
1227  Thread_Control                *offers_help,
1228  Thread_Control                *needs_help,
1229  Thread_Control                *previous_accepts_help,
1230  Scheduler_Release_idle_thread  release_idle_thread
1231)
1232{
1233  Thread_Control *next_needs_help = NULL;
1234  Thread_Control *old_user = NULL;
1235  Thread_Control *new_user = NULL;
1236
1237  if (
1238    previous_accepts_help != needs_help
1239      && _Scheduler_Thread_get_node( previous_accepts_help ) == node
1240  ) {
1241    Thread_Control *idle = _Scheduler_Release_idle_thread(
1242      context,
1243      node,
1244      release_idle_thread
1245    );
1246
1247    if ( idle != NULL ) {
1248      old_user = idle;
1249    } else {
1250      _Assert( _Scheduler_Node_get_user( node ) == previous_accepts_help );
1251      old_user = previous_accepts_help;
1252    }
1253
1254    if ( needs_help->Scheduler.state == THREAD_SCHEDULER_READY ) {
1255      new_user = needs_help;
1256    } else {
1257      _Assert(
1258        node->help_state == SCHEDULER_HELP_ACTIVE_OWNER
1259          || node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL
1260      );
1261      _Assert( offers_help->Scheduler.node == offers_help->Scheduler.own_node );
1262
1263      new_user = offers_help;
1264    }
1265
1266    if ( previous_accepts_help != offers_help ) {
1267      next_needs_help = previous_accepts_help;
1268    }
1269  } else if ( needs_help->Scheduler.state == THREAD_SCHEDULER_READY ) {
1270    Thread_Control *idle = _Scheduler_Release_idle_thread(
1271      context,
1272      node,
1273      release_idle_thread
1274    );
1275
1276    if ( idle != NULL ) {
1277      old_user = idle;
1278    } else {
1279      old_user = _Scheduler_Node_get_user( node );
1280    }
1281
1282    new_user = needs_help;
1283  } else {
1284    _Assert( needs_help->Scheduler.state == THREAD_SCHEDULER_SCHEDULED );
1285  }
1286
1287  if ( new_user != old_user ) {
1288    Per_CPU_Control *cpu_self = _Per_CPU_Get();
1289    Per_CPU_Control *cpu = _Thread_Get_CPU( old_user );
1290
1291    _Scheduler_Thread_change_state( old_user, THREAD_SCHEDULER_READY );
1292    _Scheduler_Thread_set_scheduler_and_node(
1293      old_user,
1294      _Scheduler_Thread_get_own_node( old_user ),
1295      old_user
1296    );
1297
1298    _Scheduler_Thread_change_state( new_user, THREAD_SCHEDULER_SCHEDULED );
1299    _Scheduler_Thread_set_scheduler_and_node( new_user, node, offers_help );
1300
1301    _Scheduler_Node_set_user( node, new_user );
1302    _Thread_Set_CPU( new_user, cpu );
1303    _Thread_Dispatch_update_heir( cpu_self, cpu, new_user );
1304  }
1305
1306  return next_needs_help;
1307}
1308
1309/**
1310 * @brief Asks a blocked scheduler node for help.
1311 *
1312 * @param[in] context The scheduler instance context.
1313 * @param[in] node The scheduled node offering help.
1314 * @param[in] offers_help The thread offering help.
1315 * @param[in] needs_help The thread needing help.
1316 *
1317 * @retval true Enqueue this scheduler node.
1318 * @retval false Otherwise.
1319 */
1320RTEMS_INLINE_ROUTINE bool _Scheduler_Ask_blocked_node_for_help(
1321  Scheduler_Context *context,
1322  Scheduler_Node    *node,
1323  Thread_Control    *offers_help,
1324  Thread_Control    *needs_help
1325)
1326{
1327  bool enqueue;
1328
1329  _Assert( node->help_state == SCHEDULER_HELP_PASSIVE );
1330
1331  if ( needs_help->Scheduler.state == THREAD_SCHEDULER_READY ) {
1332    _Scheduler_Node_set_user( node, needs_help );
1333    _Scheduler_Thread_set_scheduler_and_node( needs_help, node, offers_help );
1334
1335    enqueue = true;
1336  } else {
1337    enqueue = false;
1338  }
1339
1340  return enqueue;
1341}
1342#endif
1343
1344ISR_LOCK_DECLARE( extern, _Scheduler_Lock )
1345
1346RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(
1347  Thread_Control *new_heir,
1348  bool            force_dispatch
1349)
1350{
1351  Thread_Control *heir = _Thread_Heir;
1352
1353  if ( heir != new_heir && ( heir->is_preemptible || force_dispatch ) ) {
1354#if defined(RTEMS_SMP)
1355    /* We need this state only for _Thread_Get_CPU_time_used() */
1356    _Scheduler_Thread_change_state( heir, THREAD_SCHEDULER_BLOCKED );
1357    _Scheduler_Thread_change_state( new_heir, THREAD_SCHEDULER_SCHEDULED );
1358#endif
1359    _Thread_Update_CPU_time_used( heir, _Thread_Get_CPU( heir ) );
1360    _Thread_Heir = new_heir;
1361    _Thread_Dispatch_necessary = true;
1362  }
1363}
1364
1365/**
1366 * @brief Acquires the scheduler instance of the thread.
1367 *
1368 * @param[in] the_thread The thread.
1369 * @param[in] lock_context The lock context for _Scheduler_Release().
1370 */
1371RTEMS_INLINE_ROUTINE void _Scheduler_Acquire(
1372  Thread_Control   *the_thread,
1373  ISR_lock_Context *lock_context
1374)
1375{
1376  (void) the_thread;
1377  _ISR_lock_ISR_disable_and_acquire( &_Scheduler_Lock, lock_context );
1378}
1379
1380/**
1381 * @brief Releases the scheduler instance of the thread.
1382 *
1383 * @param[in] the_thread The thread.
1384 * @param[in] lock_context The lock context used for _Scheduler_Acquire().
1385 */
1386RTEMS_INLINE_ROUTINE void _Scheduler_Release(
1387  Thread_Control   *the_thread,
1388  ISR_lock_Context *lock_context
1389)
1390{
1391  (void) the_thread;
1392  _ISR_lock_Release_and_ISR_enable( &_Scheduler_Lock, lock_context );
1393}
1394
1395/** @} */
1396
1397#ifdef __cplusplus
1398}
1399#endif
1400
1401#endif
1402/* end of include file */
Note: See TracBrowser for help on using the repository browser.