source: rtems/cpukit/score/include/rtems/score/threadimpl.h @ 258ad71

5
Last change on this file since 258ad71 was 258ad71, checked in by Sebastian Huber <sebastian.huber@…>, on 09/25/15 at 12:34:24

SMP: Fix and optimize thread dispatching

According to the C11 and C++11 memory models only a read-modify-write
operation guarantees that we read the last value written in modification
order. Avoid the sequential consistent thread fence and instead use the
inter-processor interrupt to set the thread dispatch necessary
indicator.

  • Property mode set to 100644
File size: 39.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines from the Thread Handler
5 *
6 * This file contains the macro implementation of the inlined
7 * routines from the Thread handler.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2008.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  Copyright (c) 2014-2015 embedded brains GmbH.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef _RTEMS_SCORE_THREADIMPL_H
22#define _RTEMS_SCORE_THREADIMPL_H
23
24#include <rtems/score/thread.h>
25#include <rtems/score/assert.h>
26#include <rtems/score/chainimpl.h>
27#include <rtems/score/interr.h>
28#include <rtems/score/isr.h>
29#include <rtems/score/objectimpl.h>
30#include <rtems/score/resourceimpl.h>
31#include <rtems/score/statesimpl.h>
32#include <rtems/score/sysstate.h>
33#include <rtems/score/threadqimpl.h>
34#include <rtems/score/todimpl.h>
35#include <rtems/score/freechain.h>
36#include <rtems/config.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/**
43 * @addtogroup ScoreThread
44 */
45/**@{**/
46
47/**
48 *  The following structure contains the information necessary to manage
49 *  a thread which it is  waiting for a resource.
50 */
51#define THREAD_STATUS_PROXY_BLOCKING 0x1111111
52
53/**
54 *  Self for the GNU Ada Run-Time
55 */
56SCORE_EXTERN void *rtems_ada_self;
57
58typedef struct {
59  Objects_Information Objects;
60
61  Freechain_Control Free_thread_queue_heads;
62} Thread_Information;
63
64/**
65 *  The following defines the information control block used to
66 *  manage this class of objects.
67 */
68SCORE_EXTERN Thread_Information _Thread_Internal_information;
69
70/**
71 *  The following points to the thread whose floating point
72 *  context is currently loaded.
73 */
74#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
75SCORE_EXTERN Thread_Control *_Thread_Allocated_fp;
76#endif
77
78#if !defined(__DYNAMIC_REENT__)
79/**
80 * The C library re-enter-rant global pointer. Some C library implementations
81 * such as newlib have a single global pointer that changed during a context
82 * switch. The pointer points to that global pointer. The Thread control block
83 * holds a pointer to the task specific data.
84 */
85SCORE_EXTERN struct _reent **_Thread_libc_reent;
86#endif
87
88#define THREAD_CHAIN_NODE_TO_THREAD( node ) \
89  RTEMS_CONTAINER_OF( node, Thread_Control, Wait.Node.Chain )
90
91#define THREAD_RBTREE_NODE_TO_THREAD( node ) \
92  RTEMS_CONTAINER_OF( node, Thread_Control, Wait.Node.RBTree )
93
94#if defined(RTEMS_SMP)
95#define THREAD_RESOURCE_NODE_TO_THREAD( node ) \
96  RTEMS_CONTAINER_OF( node, Thread_Control, Resource_node )
97#endif
98
99void _Thread_Initialize_information(
100  Thread_Information  *information,
101  Objects_APIs         the_api,
102  uint16_t             the_class,
103  uint32_t             maximum,
104  bool                 is_string,
105  uint32_t             maximum_name_length
106#if defined(RTEMS_MULTIPROCESSING)
107  ,
108  bool                 supports_global
109#endif
110);
111
112/**
113 *  @brief Initialize thread handler.
114 *
115 *  This routine performs the initialization necessary for this handler.
116 */
117void _Thread_Handler_initialization(void);
118
119/**
120 *  @brief Create idle thread.
121 *
122 *  This routine creates the idle thread.
123 *
124 *  @warning No thread should be created before this one.
125 */
126void _Thread_Create_idle(void);
127
128/**
129 *  @brief Start thread multitasking.
130 *
131 *  This routine initiates multitasking.  It is invoked only as
132 *  part of initialization and its invocation is the last act of
133 *  the non-multitasking part of the system initialization.
134 */
135void _Thread_Start_multitasking( void ) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
136
137/**
138 *  @brief Allocate the requested stack space for the thread.
139 *
140 *  Allocate the requested stack space for the thread.
141 *  Set the Start.stack field to the address of the stack.
142 *
143 *  @param[in] the_thread is the thread where the stack space is requested
144 *  @param[in] stack_size is the stack space is requested
145 *
146 *  @retval actual size allocated after any adjustment
147 *  @retval zero if the allocation failed
148 */
149size_t _Thread_Stack_Allocate(
150  Thread_Control *the_thread,
151  size_t          stack_size
152);
153
154/**
155 *  @brief Deallocate thread stack.
156 *
157 *  Deallocate the Thread's stack.
158 */
159void _Thread_Stack_Free(
160  Thread_Control *the_thread
161);
162
163/**
164 *  @brief Initialize thread.
165 *
166 *  This routine initializes the specified the thread.  It allocates
167 *  all memory associated with this thread.  It completes by adding
168 *  the thread to the local object table so operations on this
169 *  thread id are allowed.
170 *
171 *  @note If stack_area is NULL, it is allocated from the workspace.
172 *
173 *  @note If the stack is allocated from the workspace, then it is
174 *        guaranteed to be of at least minimum size.
175 */
176bool _Thread_Initialize(
177  Thread_Information                   *information,
178  Thread_Control                       *the_thread,
179  const struct Scheduler_Control       *scheduler,
180  void                                 *stack_area,
181  size_t                                stack_size,
182  bool                                  is_fp,
183  Priority_Control                      priority,
184  bool                                  is_preemptible,
185  Thread_CPU_budget_algorithms          budget_algorithm,
186  Thread_CPU_budget_algorithm_callout   budget_callout,
187  uint32_t                              isr_level,
188  Objects_Name                          name
189);
190
191/**
192 *  @brief Initializes thread and executes it.
193 *
194 *  This routine initializes the executable information for a thread
195 *  and makes it ready to execute.  After this routine executes, the
196 *  thread competes with all other threads for CPU time.
197 *
198 *  @param the_thread is the thread to be initialized
199 *  @param the_prototype
200 *  @param entry_point
201 *  @param pointer_argument
202 *  @param numeric_argument
203 *  @param[in,out] cpu The processor if used to start an idle thread
204 *  during system initialization.  Must be set to @c NULL to start a normal
205 *  thread.
206 */
207bool _Thread_Start(
208  Thread_Control            *the_thread,
209  Thread_Start_types         the_prototype,
210  void                      *entry_point,
211  void                      *pointer_argument,
212  Thread_Entry_numeric_type  numeric_argument,
213  Per_CPU_Control           *cpu
214);
215
216bool _Thread_Restart(
217  Thread_Control            *the_thread,
218  Thread_Control            *executing,
219  void                      *pointer_argument,
220  Thread_Entry_numeric_type  numeric_argument
221);
222
223void _Thread_Yield( Thread_Control *executing );
224
225bool _Thread_Set_life_protection( bool protect );
226
227void _Thread_Life_action_handler(
228  Thread_Control  *executing,
229  Thread_Action   *action,
230  Per_CPU_Control *cpu,
231  ISR_Level        level
232);
233
234/**
235 * @brief Kills all zombie threads in the system.
236 *
237 * Threads change into the zombie state as the last step in the thread
238 * termination sequence right before a context switch to the heir thread is
239 * initiated.  Since the thread stack is still in use during this phase we have
240 * to postpone the thread stack reclamation until this point.  On SMP
241 * configurations we may have to busy wait for context switch completion here.
242 */
243void _Thread_Kill_zombies( void );
244
245/**
246 * @brief Closes the thread.
247 *
248 * Closes the thread object and starts the thread termination sequence.  In
249 * case the executing thread is not terminated, then this function waits until
250 * the terminating thread reached the zombie state.
251 */
252void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing );
253
254/**
255 * @brief Clears the specified thread state.
256 *
257 * In case the previous state is a non-ready state and the next state is the
258 * ready state, then the thread is unblocked by the scheduler.
259 *
260 * @param[in] the_thread The thread.
261 * @param[in] state The state to clear.  It must not be zero.
262 *
263 * @return The previous state.
264 */
265States_Control _Thread_Clear_state(
266  Thread_Control *the_thread,
267  States_Control  state
268);
269
270/**
271 * @brief Sets the specified thread state.
272 *
273 * In case the previous state is the ready state, then the thread is blocked by
274 * the scheduler.
275 *
276 * @param[in] the_thread The thread.
277 * @param[in] state The state to set.  It must not be zero.
278 *
279 * @return The previous state.
280 */
281States_Control _Thread_Set_state(
282  Thread_Control *the_thread,
283  States_Control  state
284);
285
286/**
287 * @brief Clears all thread states.
288 *
289 * In case the previous state is a non-ready state, then the thread is
290 * unblocked by the scheduler.
291 *
292 * @param[in] the_thread The thread.
293 */
294RTEMS_INLINE_ROUTINE void _Thread_Ready(
295  Thread_Control *the_thread
296)
297{
298  _Thread_Clear_state( the_thread, STATES_ALL_SET );
299}
300
301/**
302 *  @brief Initializes enviroment for a thread.
303 *
304 *  This routine initializes the context of @a the_thread to its
305 *  appropriate starting state.
306 *
307 *  @param[in] the_thread is the pointer to the thread control block.
308 */
309void _Thread_Load_environment(
310  Thread_Control *the_thread
311);
312
313/**
314 *  @brief Wrapper function for all threads.
315 *
316 *  This routine is the wrapper function for all threads.  It is
317 *  the starting point for all threads.  The user provided thread
318 *  entry point is invoked by this routine.  Operations
319 *  which must be performed immediately before and after the user's
320 *  thread executes are found here.
321 *
322 *  @note On entry, it is assumed all interrupts are blocked and that this
323 *  routine needs to set the initial isr level.  This may or may not
324 *  actually be needed by the context switch routine and as a result
325 *  interrupts may already be at there proper level.  Either way,
326 *  setting the initial isr level properly here is safe.
327 */
328void _Thread_Handler( void );
329
330/**
331 * @brief Executes the global constructors and then restarts itself as the
332 * first initialization thread.
333 *
334 * The first initialization thread is the first RTEMS initialization task or
335 * the first POSIX initialization thread in case no RTEMS initialization tasks
336 * are present.
337 */
338void *_Thread_Global_construction( void );
339
340/**
341 *  @brief Ended the delay of a thread.
342 *
343 *  This routine is invoked when a thread must be unblocked at the
344 *  end of a time based delay (i.e. wake after or wake when).
345 *  It is called by the watchdog handler.
346 *
347 *  @param[in] id is the thread id
348 *  @param[in] ignored is not used
349 */
350void _Thread_Delay_ended(
351  Objects_Id  id,
352  void       *ignored
353);
354
355/**
356 * @brief Returns true if the left thread priority is less than the right
357 * thread priority in the intuitive sense of priority and false otherwise.
358 */
359RTEMS_INLINE_ROUTINE bool _Thread_Priority_less_than(
360  Priority_Control left,
361  Priority_Control right
362)
363{
364  return left > right;
365}
366
367/**
368 * @brief Returns the highest priority of the left and right thread priorities
369 * in the intuitive sense of priority.
370 */
371RTEMS_INLINE_ROUTINE Priority_Control _Thread_Priority_highest(
372  Priority_Control left,
373  Priority_Control right
374)
375{
376  return _Thread_Priority_less_than( left, right ) ? right : left;
377}
378
379/**
380 * @brief Filters a thread priority change.
381 *
382 * Called by _Thread_Change_priority() under the protection of the thread lock.
383 *
384 * @param[in] the_thread The thread.
385 * @param[in, out] new_priority The new priority of the thread.  The filter may
386 * alter this value.
387 * @param[in] arg The argument passed to _Thread_Change_priority().
388 *
389 * @retval true Change the current priority.
390 * @retval false Otherwise.
391 */
392typedef bool ( *Thread_Change_priority_filter )(
393  Thread_Control   *the_thread,
394  Priority_Control *new_priority,
395  void             *arg
396);
397
398/**
399 * @brief Changes the priority of a thread if allowed by the filter function.
400 *
401 * It changes current priority of the thread to the new priority in case the
402 * filter function returns true.  In this case the scheduler is notified of the
403 * priority change as well.
404 *
405 * @param[in] the_thread The thread.
406 * @param[in] new_priority The new priority of the thread.
407 * @param[in] arg The argument for the filter function.
408 * @param[in] filter The filter function to determine if a priority change is
409 * allowed and optionally perform other actions under the protection of the
410 * thread lock simultaneously with the update of the current priority.
411 * @param[in] prepend_it In case this is true, then the thread is prepended to
412 * its priority group in its scheduler instance, otherwise it is appended.
413 */
414void _Thread_Change_priority(
415  Thread_Control                *the_thread,
416  Priority_Control               new_priority,
417  void                          *arg,
418  Thread_Change_priority_filter  filter,
419  bool                           prepend_it
420);
421
422/**
423 * @brief Raises the priority of a thread.
424 *
425 * It changes the current priority of the thread to the new priority if the new
426 * priority is higher than the current priority.  In this case the thread is
427 * appended to its new priority group in its scheduler instance.
428 *
429 * @param[in] the_thread The thread.
430 * @param[in] new_priority The new priority of the thread.
431 *
432 * @see _Thread_Change_priority().
433 */
434void _Thread_Raise_priority(
435  Thread_Control   *the_thread,
436  Priority_Control  new_priority
437);
438
439/**
440 * @brief Inherit the priority of a thread.
441 *
442 * It changes the current priority of the inheritor thread to the current priority
443 * of the ancestor thread if it is higher than the current priority of the inheritor
444 * thread.  In this case the inheritor thread is appended to its new priority group
445 * in its scheduler instance.
446 *
447 * On SMP configurations, the priority is changed to PRIORITY_PSEUDO_ISR in
448 * case the own schedulers of the inheritor and ancestor thread differ (priority
449 * boosting).
450 *
451 * @param[in] inheritor The thread to inherit the priority.
452 * @param[in] ancestor The thread to bequeath its priority to the inheritor
453 *   thread.
454 */
455#if defined(RTEMS_SMP)
456void _Thread_Inherit_priority(
457  Thread_Control *inheritor,
458  Thread_Control *ancestor
459);
460#else
461RTEMS_INLINE_ROUTINE void _Thread_Inherit_priority(
462  Thread_Control *inheritor,
463  Thread_Control *ancestor
464)
465{
466  _Thread_Raise_priority( inheritor, ancestor->current_priority );
467}
468#endif
469
470/**
471 * @brief Sets the current to the real priority of a thread.
472 *
473 * Sets the priority restore hint to false.
474 */
475void _Thread_Restore_priority( Thread_Control *the_thread );
476
477/**
478 * @brief Sets the priority of a thread.
479 *
480 * It sets the real priority of the thread.  In addition it changes the current
481 * priority of the thread if the new priority is higher than the current
482 * priority or the thread owns no resources.
483 *
484 * @param[in] the_thread The thread.
485 * @param[in] new_priority The new priority of the thread.
486 * @param[out] old_priority The old real priority of the thread.  This pointer
487 * must not be @c NULL.
488 * @param[in] prepend_it In case this is true, then the thread is prepended to
489 * its priority group in its scheduler instance, otherwise it is appended.
490 *
491 * @see _Thread_Change_priority().
492 */
493void _Thread_Set_priority(
494  Thread_Control   *the_thread,
495  Priority_Control  new_priority,
496  Priority_Control *old_priority,
497  bool              prepend_it
498);
499
500/**
501 *  @brief Maps thread Id to a TCB pointer.
502 *
503 *  This function maps thread IDs to thread control
504 *  blocks.  If ID corresponds to a local thread, then it
505 *  returns the_thread control pointer which maps to ID
506 *  and @a location is set to OBJECTS_LOCAL.  If the thread ID is
507 *  global and resides on a remote node, then location is set
508 *  to OBJECTS_REMOTE, and the_thread is undefined.
509 *  Otherwise, location is set to OBJECTS_ERROR and
510 *  the_thread is undefined.
511 *
512 *  @param[in] id is the id of the thread.
513 *  @param[in] location is the location of the block.
514 *
515 *  @note  The performance of many RTEMS services depends upon
516 *         the quick execution of the "good object" path in this
517 *         routine.  If there is a possibility of saving a few
518 *         cycles off the execution time, this routine is worth
519 *         further optimization attention.
520 */
521Thread_Control *_Thread_Get (
522  Objects_Id         id,
523  Objects_Locations *location
524);
525
526/**
527 * @brief Gets a thread by its identifier.
528 *
529 * @see _Objects_Get_isr_disable().
530 */
531Thread_Control *_Thread_Get_interrupt_disable(
532  Objects_Id         id,
533  Objects_Locations *location,
534  ISR_lock_Context  *lock_context
535);
536
537RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU(
538  const Thread_Control *thread
539)
540{
541#if defined(RTEMS_SMP)
542  return thread->Scheduler.cpu;
543#else
544  (void) thread;
545
546  return _Per_CPU_Get();
547#endif
548}
549
550RTEMS_INLINE_ROUTINE void _Thread_Set_CPU(
551  Thread_Control *thread,
552  Per_CPU_Control *cpu
553)
554{
555#if defined(RTEMS_SMP)
556  thread->Scheduler.cpu = cpu;
557#else
558  (void) thread;
559  (void) cpu;
560#endif
561}
562
563/**
564 * This function returns true if the_thread is the currently executing
565 * thread, and false otherwise.
566 */
567
568RTEMS_INLINE_ROUTINE bool _Thread_Is_executing (
569  const Thread_Control *the_thread
570)
571{
572  return ( the_thread == _Thread_Executing );
573}
574
575#if defined(RTEMS_SMP)
576/**
577 * @brief Returns @a true in case the thread executes currently on some
578 * processor in the system, otherwise @a false.
579 *
580 * Do not confuse this with _Thread_Is_executing() which checks only the
581 * current processor.
582 */
583RTEMS_INLINE_ROUTINE bool _Thread_Is_executing_on_a_processor(
584  const Thread_Control *the_thread
585)
586{
587  return _CPU_Context_Get_is_executing( &the_thread->Registers );
588}
589#endif
590
591/**
592 * @brief Returns @a true and sets time_of_context_switch to the
593 * time of the last context switch when the thread is currently executing
594 * in the system, otherwise @a false.
595 */
596RTEMS_INLINE_ROUTINE bool _Thread_Get_time_of_last_context_switch(
597  Thread_Control    *the_thread,
598  Timestamp_Control *time_of_context_switch
599)
600{
601  bool retval = false;
602
603  _Thread_Disable_dispatch();
604  #ifndef RTEMS_SMP
605    if ( _Thread_Executing->Object.id == the_thread->Object.id ) {
606      *time_of_context_switch = _Thread_Time_of_last_context_switch;
607      retval = true;
608    }
609  #else
610    if ( _Thread_Is_executing_on_a_processor( the_thread ) ) {
611      *time_of_context_switch =
612        _Thread_Get_CPU( the_thread )->time_of_last_context_switch;
613      retval = true;
614    }
615  #endif
616  _Thread_Enable_dispatch();
617  return retval;
618}
619
620
621/**
622 * This function returns true if the_thread is the heir
623 * thread, and false otherwise.
624 */
625
626RTEMS_INLINE_ROUTINE bool _Thread_Is_heir (
627  const Thread_Control *the_thread
628)
629{
630  return ( the_thread == _Thread_Heir );
631}
632
633/**
634 * This routine clears any blocking state for the_thread.  It performs
635 * any necessary scheduling operations including the selection of
636 * a new heir thread.
637 */
638
639RTEMS_INLINE_ROUTINE void _Thread_Unblock (
640  Thread_Control *the_thread
641)
642{
643  _Thread_Clear_state( the_thread, STATES_BLOCKED );
644}
645
646/**
647 * This routine resets the current context of the calling thread
648 * to that of its initial state.
649 */
650
651RTEMS_INLINE_ROUTINE void _Thread_Restart_self( Thread_Control *executing )
652{
653#if defined(RTEMS_SMP)
654  ISR_Level level;
655
656  _Giant_Release( _Per_CPU_Get() );
657
658  _ISR_Disable_without_giant( level );
659  ( void ) level;
660#endif
661
662#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
663  if ( executing->fp_context != NULL )
664    _Context_Restore_fp( &executing->fp_context );
665#endif
666
667  _CPU_Context_Restart_self( &executing->Registers );
668}
669
670/**
671 * This function returns true if the floating point context of
672 * the_thread is currently loaded in the floating point unit, and
673 * false otherwise.
674 */
675
676#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
677RTEMS_INLINE_ROUTINE bool _Thread_Is_allocated_fp (
678  const Thread_Control *the_thread
679)
680{
681  return ( the_thread == _Thread_Allocated_fp );
682}
683#endif
684
685/*
686 *  If the CPU has hardware floating point, then we must address saving
687 *  and restoring it as part of the context switch.
688 *
689 *  The second conditional compilation section selects the algorithm used
690 *  to context switch between floating point tasks.  The deferred algorithm
691 *  can be significantly better in a system with few floating point tasks
692 *  because it reduces the total number of save and restore FP context
693 *  operations.  However, this algorithm can not be used on all CPUs due
694 *  to unpredictable use of FP registers by some compilers for integer
695 *  operations.
696 */
697
698RTEMS_INLINE_ROUTINE void _Thread_Save_fp( Thread_Control *executing )
699{
700#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
701#if ( CPU_USE_DEFERRED_FP_SWITCH != TRUE )
702  if ( executing->fp_context != NULL )
703    _Context_Save_fp( &executing->fp_context );
704#endif
705#endif
706}
707
708RTEMS_INLINE_ROUTINE void _Thread_Restore_fp( Thread_Control *executing )
709{
710#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
711#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
712  if ( (executing->fp_context != NULL) &&
713       !_Thread_Is_allocated_fp( executing ) ) {
714    if ( _Thread_Allocated_fp != NULL )
715      _Context_Save_fp( &_Thread_Allocated_fp->fp_context );
716    _Context_Restore_fp( &executing->fp_context );
717    _Thread_Allocated_fp = executing;
718  }
719#else
720  if ( executing->fp_context != NULL )
721    _Context_Restore_fp( &executing->fp_context );
722#endif
723#endif
724}
725
726/**
727 * This routine is invoked when the currently loaded floating
728 * point context is now longer associated with an active thread.
729 */
730
731#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
732RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void )
733{
734  _Thread_Allocated_fp = NULL;
735}
736#endif
737
738/**
739 * This function returns true if dispatching is disabled, and false
740 * otherwise.
741 */
742
743RTEMS_INLINE_ROUTINE bool _Thread_Is_context_switch_necessary( void )
744{
745  return ( _Thread_Dispatch_necessary );
746}
747
748/**
749 * This function returns true if the_thread is NULL and false otherwise.
750 */
751
752RTEMS_INLINE_ROUTINE bool _Thread_Is_null (
753  const Thread_Control *the_thread
754)
755{
756  return ( the_thread == NULL );
757}
758
759/**
760 * @brief Is proxy blocking.
761 *
762 * status which indicates that a proxy is blocking, and false otherwise.
763 */
764RTEMS_INLINE_ROUTINE bool _Thread_Is_proxy_blocking (
765  uint32_t   code
766)
767{
768  return (code == THREAD_STATUS_PROXY_BLOCKING);
769}
770
771RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void)
772{
773  /* Idle threads */
774  uint32_t maximum_internal_threads =
775    rtems_configuration_get_maximum_processors();
776
777  /* MPCI thread */
778#if defined(RTEMS_MULTIPROCESSING)
779  if ( _System_state_Is_multiprocessing ) {
780    ++maximum_internal_threads;
781  }
782#endif
783
784  return maximum_internal_threads;
785}
786
787RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void )
788{
789  return (Thread_Control *)
790    _Objects_Allocate_unprotected( &_Thread_Internal_information.Objects );
791}
792
793/**
794 * @brief Gets the heir of the processor and makes it executing.
795 *
796 * Must be called with interrupts disabled.  The thread dispatch necessary
797 * indicator is cleared as a side-effect.
798 *
799 * @return The heir thread.
800 *
801 * @see _Thread_Dispatch(), _Thread_Start_multitasking() and
802 * _Thread_Dispatch_update_heir().
803 */
804RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing(
805  Per_CPU_Control *cpu_self
806)
807{
808  Thread_Control *heir;
809
810  heir = cpu_self->heir;
811  cpu_self->dispatch_necessary = false;
812  cpu_self->executing = heir;
813
814  return heir;
815}
816
817#if defined( RTEMS_SMP )
818RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir(
819  Per_CPU_Control *cpu_self,
820  Per_CPU_Control *cpu_for_heir,
821  Thread_Control  *heir
822)
823{
824  cpu_for_heir->heir = heir;
825
826  if ( cpu_for_heir == cpu_self ) {
827    cpu_self->dispatch_necessary = true;
828  } else {
829    _Per_CPU_Send_interrupt( cpu_for_heir );
830  }
831}
832#endif
833
834RTEMS_INLINE_ROUTINE void _Thread_Update_cpu_time_used(
835  Thread_Control *executing,
836  Timestamp_Control *time_of_last_context_switch
837)
838{
839  Timestamp_Control uptime;
840  Timestamp_Control ran;
841
842  _TOD_Get_uptime( &uptime );
843  _Timestamp_Subtract(
844    time_of_last_context_switch,
845    &uptime,
846    &ran
847  );
848  *time_of_last_context_switch = uptime;
849  _Timestamp_Add_to( &executing->cpu_time_used, &ran );
850}
851
852RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize(
853  Thread_Action_control *action_control
854)
855{
856  _Chain_Initialize_empty( &action_control->Chain );
857}
858
859RTEMS_INLINE_ROUTINE void _Thread_Action_initialize(
860  Thread_Action         *action,
861  Thread_Action_handler  handler
862)
863{
864  action->handler = handler;
865  _Chain_Set_off_chain( &action->Node );
866}
867
868RTEMS_INLINE_ROUTINE Per_CPU_Control *
869  _Thread_Action_ISR_disable_and_acquire_for_executing( ISR_Level *level )
870{
871  Per_CPU_Control *cpu;
872
873  _ISR_Disable_without_giant( *level );
874  cpu = _Per_CPU_Get();
875  _Per_CPU_Acquire( cpu );
876
877  return cpu;
878}
879
880RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Action_ISR_disable_and_acquire(
881  Thread_Control *thread,
882  ISR_Level      *level
883)
884{
885  Per_CPU_Control *cpu;
886
887  _ISR_Disable_without_giant( *level );
888  cpu = _Thread_Get_CPU( thread );
889  _Per_CPU_Acquire( cpu );
890
891  return cpu;
892}
893
894RTEMS_INLINE_ROUTINE void _Thread_Action_release_and_ISR_enable(
895  Per_CPU_Control *cpu,
896  ISR_Level level
897)
898{
899  _Per_CPU_Release_and_ISR_enable( cpu, level );
900}
901
902RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
903  Thread_Control *thread,
904  Thread_Action  *action
905)
906{
907  Per_CPU_Control *cpu_of_thread;
908  ISR_Level        level;
909
910  cpu_of_thread = _Thread_Action_ISR_disable_and_acquire( thread, &level );
911
912#if defined(RTEMS_SMP)
913  if ( _Per_CPU_Get() == cpu_of_thread ) {
914    cpu_of_thread->dispatch_necessary = true;
915  } else {
916    _Per_CPU_Send_interrupt( cpu_of_thread );
917  }
918#else
919  cpu_of_thread->dispatch_necessary = true;
920#endif
921
922  _Chain_Append_if_is_off_chain_unprotected(
923    &thread->Post_switch_actions.Chain,
924    &action->Node
925  );
926
927  _Thread_Action_release_and_ISR_enable( cpu_of_thread, level );
928}
929
930RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting(
931  Thread_Life_state life_state
932)
933{
934  return ( life_state & THREAD_LIFE_RESTARTING ) != 0;
935}
936
937RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating(
938  Thread_Life_state life_state
939)
940{
941  return ( life_state & THREAD_LIFE_TERMINATING ) != 0;
942}
943
944RTEMS_INLINE_ROUTINE bool _Thread_Is_life_protected(
945  Thread_Life_state life_state
946)
947{
948  return ( life_state & THREAD_LIFE_PROTECTED ) != 0;
949}
950
951RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing(
952  Thread_Life_state life_state
953)
954{
955  return ( life_state & THREAD_LIFE_RESTARTING_TERMINATING ) != 0;
956}
957
958/**
959 * @brief Returns true if the thread owns resources, and false otherwise.
960 *
961 * Resources are accounted with the Thread_Control::resource_count resource
962 * counter.  This counter is used by semaphore objects for example.
963 *
964 * In addition to the resource counter there is a resource dependency tree
965 * available on SMP configurations.  In case this tree is non-empty, then the
966 * thread owns resources.
967 *
968 * @param[in] the_thread The thread.
969 */
970RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
971  const Thread_Control *the_thread
972)
973{
974  bool owns_resources = the_thread->resource_count != 0;
975
976#if defined(RTEMS_SMP)
977  owns_resources = owns_resources
978    || _Resource_Node_owns_resources( &the_thread->Resource_node );
979#endif
980
981  return owns_resources;
982}
983
984/**
985 * @brief Acquires the default thread lock inside a critical section
986 * (interrupts disabled).
987 *
988 * @param[in] the_thread The thread.
989 * @param[in] lock_context The lock context used for the corresponding lock
990 * release.
991 *
992 * @see _Thread_Lock_release_default().
993 */
994RTEMS_INLINE_ROUTINE void _Thread_Lock_acquire_default_critical(
995  Thread_Control   *the_thread,
996  ISR_lock_Context *lock_context
997)
998{
999  _Assert( _ISR_Get_level() != 0 );
1000#if defined(RTEMS_SMP)
1001  _SMP_ticket_lock_Acquire(
1002    &the_thread->Lock.Default,
1003    &_Thread_Executing->Lock.Stats,
1004    &lock_context->Lock_context.Stats_context
1005  );
1006#else
1007  (void) the_thread;
1008  (void) lock_context;
1009#endif
1010}
1011
1012/**
1013 * @brief Acquires the default thread lock and returns the executing thread.
1014 *
1015 * @param[in] lock_context The lock context used for the corresponding lock
1016 * release.
1017 *
1018 * @return The executing thread.
1019 *
1020 * @see _Thread_Lock_release_default().
1021 */
1022RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Lock_acquire_default_for_executing(
1023  ISR_lock_Context *lock_context
1024)
1025{
1026  Thread_Control *executing;
1027
1028  _ISR_lock_ISR_disable( lock_context );
1029  executing = _Thread_Executing;
1030  _Thread_Lock_acquire_default_critical( executing, lock_context );
1031
1032  return executing;
1033}
1034
1035/**
1036 * @brief Acquires the default thread lock.
1037 *
1038 * @param[in] the_thread The thread.
1039 * @param[in] lock_context The lock context used for the corresponding lock
1040 * release.
1041 *
1042 * @see _Thread_Lock_release_default().
1043 */
1044RTEMS_INLINE_ROUTINE void _Thread_Lock_acquire_default(
1045  Thread_Control   *the_thread,
1046  ISR_lock_Context *lock_context
1047)
1048{
1049  _ISR_lock_ISR_disable( lock_context );
1050  _Thread_Lock_acquire_default_critical( the_thread, lock_context );
1051}
1052
1053/**
1054 * @brief Releases the thread lock inside a critical section (interrupts
1055 * disabled).
1056 *
1057 * The previous interrupt status is not restored.
1058 *
1059 * @param[in] lock The lock.
1060 * @param[in] lock_context The lock context used for the corresponding lock
1061 * acquire.
1062 */
1063RTEMS_INLINE_ROUTINE void _Thread_Lock_release_critical(
1064  void             *lock,
1065  ISR_lock_Context *lock_context
1066)
1067{
1068#if defined(RTEMS_SMP)
1069  _SMP_ticket_lock_Release(
1070    lock,
1071    &lock_context->Lock_context.Stats_context
1072  );
1073#else
1074  (void) lock;
1075  (void) lock_context;
1076#endif
1077}
1078
1079/**
1080 * @brief Releases the thread lock.
1081 *
1082 * @param[in] lock The lock returned by _Thread_Lock_acquire().
1083 * @param[in] lock_context The lock context used for _Thread_Lock_acquire().
1084 */
1085RTEMS_INLINE_ROUTINE void _Thread_Lock_release(
1086  void             *lock,
1087  ISR_lock_Context *lock_context
1088)
1089{
1090  _Thread_Lock_release_critical( lock, lock_context );
1091  _ISR_lock_ISR_enable( lock_context );
1092}
1093
1094/**
1095 * @brief Releases the default thread lock inside a critical section
1096 * (interrupts disabled).
1097 *
1098 * The previous interrupt status is not restored.
1099 *
1100 * @param[in] the_thread The thread.
1101 * @param[in] lock_context The lock context used for the corresponding lock
1102 * acquire.
1103 */
1104RTEMS_INLINE_ROUTINE void _Thread_Lock_release_default_critical(
1105  Thread_Control   *the_thread,
1106  ISR_lock_Context *lock_context
1107)
1108{
1109  _Thread_Lock_release_critical(
1110#if defined(RTEMS_SMP)
1111    &the_thread->Lock.Default,
1112#else
1113    NULL,
1114#endif
1115    lock_context
1116  );
1117}
1118
1119/**
1120 * @brief Releases the default thread lock.
1121 *
1122 * @param[in] the_thread The thread.
1123 * @param[in] lock_context The lock context used for the corresponding lock
1124 * acquire.
1125 */
1126RTEMS_INLINE_ROUTINE void _Thread_Lock_release_default(
1127  Thread_Control   *the_thread,
1128  ISR_lock_Context *lock_context
1129)
1130{
1131  _Thread_Lock_release_default_critical( the_thread, lock_context );
1132  _ISR_lock_ISR_enable( lock_context );
1133}
1134
1135/**
1136 * @brief Acquires the thread lock.
1137 *
1138 * @param[in] the_thread The thread.
1139 * @param[in] lock_context The lock context for _Thread_Lock_release().
1140 *
1141 * @return The lock required by _Thread_Lock_release().
1142 */
1143RTEMS_INLINE_ROUTINE void *_Thread_Lock_acquire(
1144  Thread_Control   *the_thread,
1145  ISR_lock_Context *lock_context
1146)
1147{
1148#if defined(RTEMS_SMP)
1149  SMP_ticket_lock_Control *lock;
1150
1151  while ( true ) {
1152    unsigned int first_generation;
1153    unsigned int second_generation;
1154
1155    _ISR_lock_ISR_disable( lock_context );
1156
1157    /*
1158     * Ensure that we read our first lock generation before we obtain our
1159     * current lock.  See _Thread_Lock_set_unprotected().
1160     */
1161    first_generation = _Atomic_Load_uint(
1162      &the_thread->Lock.generation,
1163      ATOMIC_ORDER_ACQUIRE
1164    );
1165
1166    lock = the_thread->Lock.current;
1167    _SMP_ticket_lock_Acquire(
1168      lock,
1169      &_Thread_Executing->Lock.Stats,
1170      &lock_context->Lock_context.Stats_context
1171    );
1172
1173    /*
1174     * The C11 memory model doesn't guarantee that we read the latest
1175     * generation here.  For this a read-modify-write operation would be
1176     * necessary.  We read at least the new generation set up by the owner of
1177     * our current thread lock, and so on.
1178     */
1179    second_generation = _Atomic_Load_uint(
1180      &the_thread->Lock.generation,
1181      ATOMIC_ORDER_ACQUIRE
1182    );
1183
1184    if ( first_generation == second_generation ) {
1185      return lock;
1186    }
1187
1188    _Thread_Lock_release( lock, lock_context );
1189  }
1190#else
1191  _ISR_Disable( lock_context->isr_level );
1192
1193  return NULL;
1194#endif
1195}
1196
1197#if defined(RTEMS_SMP)
1198/*
1199 * Internal function, use _Thread_Lock_set() or _Thread_Lock_restore_default()
1200 * instead.
1201 */
1202RTEMS_INLINE_ROUTINE void _Thread_Lock_set_unprotected(
1203  Thread_Control          *the_thread,
1204  SMP_ticket_lock_Control *new_lock
1205)
1206{
1207  the_thread->Lock.current = new_lock;
1208
1209  /*
1210   * The generation release corresponds to the generation acquire in
1211   * _Thread_Lock_acquire() and ensures that the new lock and other fields are
1212   * visible to the next thread lock owner.  Otherwise someone would be able to
1213   * read an up to date generation number and an old lock.  See
1214   * _Thread_Wait_set_queue() and _Thread_Wait_restore_default_operations().
1215   *
1216   * Since we set a new lock right before, this increment is not protected by a
1217   * lock and thus must be an atomic operation.
1218   */
1219  _Atomic_Fetch_add_uint(
1220    &the_thread->Lock.generation,
1221    1,
1222    ATOMIC_ORDER_RELEASE
1223  );
1224}
1225#endif
1226
1227/**
1228 * @brief Sets a new thread lock.
1229 *
1230 * The caller must not be the owner of the default thread lock.  The caller
1231 * must be the owner of the new lock.
1232 *
1233 * @param[in] the_thread The thread.
1234 * @param[in] new_lock The new thread lock.
1235 */
1236#if defined(RTEMS_SMP)
1237RTEMS_INLINE_ROUTINE void _Thread_Lock_set(
1238  Thread_Control          *the_thread,
1239  SMP_ticket_lock_Control *new_lock
1240)
1241{
1242  ISR_lock_Context lock_context;
1243
1244  _Thread_Lock_acquire_default_critical( the_thread, &lock_context );
1245  _Assert( the_thread->Lock.current == &the_thread->Lock.Default );
1246  _Thread_Lock_set_unprotected( the_thread, new_lock );
1247  _Thread_Lock_release_default_critical( the_thread, &lock_context );
1248}
1249#else
1250#define _Thread_Lock_set( the_thread, new_lock ) \
1251  do { } while ( 0 )
1252#endif
1253
1254/**
1255 * @brief Restores the default thread lock.
1256 *
1257 * The caller must be the owner of the current thread lock.
1258 *
1259 * @param[in] the_thread The thread.
1260 */
1261#if defined(RTEMS_SMP)
1262RTEMS_INLINE_ROUTINE void _Thread_Lock_restore_default(
1263  Thread_Control *the_thread
1264)
1265{
1266  _Thread_Lock_set_unprotected( the_thread, &the_thread->Lock.Default );
1267}
1268#else
1269#define _Thread_Lock_restore_default( the_thread ) \
1270  do { } while ( 0 )
1271#endif
1272
1273/**
1274 * @brief The initial thread wait flags value set by _Thread_Initialize().
1275 */
1276#define THREAD_WAIT_FLAGS_INITIAL 0x0U
1277
1278/**
1279 * @brief Mask to get the thread wait state flags.
1280 */
1281#define THREAD_WAIT_STATE_MASK 0xffU
1282
1283/**
1284 * @brief Indicates that the thread begins with the blocking operation.
1285 *
1286 * A blocking operation consists of an optional watchdog initialization and the
1287 * setting of the appropriate thread blocking state with the corresponding
1288 * scheduler block operation.
1289 */
1290#define THREAD_WAIT_STATE_INTEND_TO_BLOCK 0x1U
1291
1292/**
1293 * @brief Indicates that the thread completed the blocking operation.
1294 */
1295#define THREAD_WAIT_STATE_BLOCKED 0x2U
1296
1297/**
1298 * @brief Indicates that a condition to end the thread wait occurred.
1299 *
1300 * This could be a timeout, a signal, an event or a resource availability.
1301 */
1302#define THREAD_WAIT_STATE_READY_AGAIN 0x4U
1303
1304/**
1305 * @brief Mask to get the thread wait class flags.
1306 */
1307#define THREAD_WAIT_CLASS_MASK 0xff00U
1308
1309/**
1310 * @brief Indicates that the thread waits for an event.
1311 */
1312#define THREAD_WAIT_CLASS_EVENT 0x100U
1313
1314/**
1315 * @brief Indicates that the thread waits for a system event.
1316 */
1317#define THREAD_WAIT_CLASS_SYSTEM_EVENT 0x200U
1318
1319/**
1320 * @brief Indicates that the thread waits for a object.
1321 */
1322#define THREAD_WAIT_CLASS_OBJECT 0x400U
1323
1324RTEMS_INLINE_ROUTINE void _Thread_Wait_flags_set(
1325  Thread_Control    *the_thread,
1326  Thread_Wait_flags  flags
1327)
1328{
1329#if defined(RTEMS_SMP)
1330  _Atomic_Store_uint( &the_thread->Wait.flags, flags, ATOMIC_ORDER_RELAXED );
1331#else
1332  the_thread->Wait.flags = flags;
1333#endif
1334}
1335
1336RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get(
1337  const Thread_Control *the_thread
1338)
1339{
1340#if defined(RTEMS_SMP)
1341  return _Atomic_Load_uint( &the_thread->Wait.flags, ATOMIC_ORDER_RELAXED );
1342#else
1343  return the_thread->Wait.flags;
1344#endif
1345}
1346
1347/**
1348 * @brief Tries to change the thread wait flags inside a critical section
1349 * (interrupts disabled).
1350 *
1351 * In case the wait flags are equal to the expected wait flags, then the wait
1352 * flags are set to the desired wait flags.
1353 *
1354 * @param[in] the_thread The thread.
1355 * @param[in] expected_flags The expected wait flags.
1356 * @param[in] desired_flags The desired wait flags.
1357 *
1358 * @retval true The wait flags were equal to the expected wait flags.
1359 * @retval false Otherwise.
1360 */
1361RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_critical(
1362  Thread_Control    *the_thread,
1363  Thread_Wait_flags  expected_flags,
1364  Thread_Wait_flags  desired_flags
1365)
1366{
1367#if defined(RTEMS_SMP)
1368  return _Atomic_Compare_exchange_uint(
1369    &the_thread->Wait.flags,
1370    &expected_flags,
1371    desired_flags,
1372    ATOMIC_ORDER_RELAXED,
1373    ATOMIC_ORDER_RELAXED
1374  );
1375#else
1376  bool success = the_thread->Wait.flags == expected_flags;
1377
1378  if ( success ) {
1379    the_thread->Wait.flags = desired_flags;
1380  }
1381
1382  return success;
1383#endif
1384}
1385
1386/**
1387 * @brief Tries to change the thread wait flags.
1388 *
1389 * @see _Thread_Wait_flags_try_change_critical().
1390 */
1391RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change(
1392  Thread_Control    *the_thread,
1393  Thread_Wait_flags  expected_flags,
1394  Thread_Wait_flags  desired_flags
1395)
1396{
1397  bool success;
1398#if !defined(RTEMS_SMP)
1399  ISR_Level level;
1400
1401  _ISR_Disable_without_giant( level );
1402#endif
1403
1404  success = _Thread_Wait_flags_try_change_critical(
1405    the_thread,
1406    expected_flags,
1407    desired_flags
1408  );
1409
1410#if !defined(RTEMS_SMP)
1411  _ISR_Enable_without_giant( level );
1412#endif
1413
1414  return success;
1415}
1416
1417/**
1418 * @brief Sets the thread queue.
1419 *
1420 * The caller must be the owner of the thread lock.
1421 *
1422 * @param[in] the_thread The thread.
1423 * @param[in] new_queue The new queue.
1424 *
1425 * @see _Thread_Lock_set().
1426 */
1427RTEMS_INLINE_ROUTINE void _Thread_Wait_set_queue(
1428  Thread_Control     *the_thread,
1429  Thread_queue_Queue *new_queue
1430)
1431{
1432  the_thread->Wait.queue = new_queue;
1433}
1434
1435/**
1436 * @brief Sets the thread queue operations.
1437 *
1438 * The caller must be the owner of the thread lock.
1439 *
1440 * @param[in] the_thread The thread.
1441 * @param[in] new_operations The new queue operations.
1442 *
1443 * @see _Thread_Lock_set() and _Thread_Wait_restore_default_operations().
1444 */
1445RTEMS_INLINE_ROUTINE void _Thread_Wait_set_operations(
1446  Thread_Control                *the_thread,
1447  const Thread_queue_Operations *new_operations
1448)
1449{
1450  the_thread->Wait.operations = new_operations;
1451}
1452
1453/**
1454 * @brief Restores the default thread queue operations.
1455 *
1456 * The caller must be the owner of the thread lock.
1457 *
1458 * @param[in] the_thread The thread.
1459 *
1460 * @see _Thread_Wait_set_operations().
1461 */
1462RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default_operations(
1463  Thread_Control *the_thread
1464)
1465{
1466  the_thread->Wait.operations = &_Thread_queue_Operations_default;
1467}
1468
1469/**
1470 * @brief Sets the thread wait timeout code.
1471 *
1472 * @param[in] the_thread The thread.
1473 * @param[in] timeout_code The new thread wait timeout code.
1474 */
1475RTEMS_INLINE_ROUTINE void _Thread_Wait_set_timeout_code(
1476  Thread_Control *the_thread,
1477  uint32_t        timeout_code
1478)
1479{
1480  the_thread->Wait.timeout_code = timeout_code;
1481}
1482
1483/**
1484 * @brief General purpose thread wait timeout.
1485 *
1486 * @param[in] id Unused.
1487 * @param[in] arg The thread.
1488 */
1489void _Thread_Timeout( Objects_Id id, void *arg );
1490
1491RTEMS_INLINE_ROUTINE void _Thread_Debug_set_real_processor(
1492  Thread_Control  *the_thread,
1493  Per_CPU_Control *cpu
1494)
1495{
1496#if defined(RTEMS_SMP) && defined(RTEMS_DEBUG)
1497  the_thread->Scheduler.debug_real_cpu = cpu;
1498#else
1499  (void) the_thread;
1500  (void) cpu;
1501#endif
1502}
1503
1504#if !defined(__DYNAMIC_REENT__)
1505/**
1506 * This routine returns the C library re-enterant pointer.
1507 */
1508
1509RTEMS_INLINE_ROUTINE struct _reent **_Thread_Get_libc_reent( void )
1510{
1511  return _Thread_libc_reent;
1512}
1513
1514/**
1515 * This routine set the C library re-enterant pointer.
1516 */
1517
1518RTEMS_INLINE_ROUTINE void _Thread_Set_libc_reent (
1519  struct _reent **libc_reent
1520)
1521{
1522  _Thread_libc_reent = libc_reent;
1523}
1524#endif
1525
1526/** @}*/
1527
1528#ifdef __cplusplus
1529}
1530#endif
1531
1532#if defined(RTEMS_MULTIPROCESSING)
1533#include <rtems/score/threadmp.h>
1534#endif
1535
1536#endif
1537/* end of include file */
Note: See TracBrowser for help on using the repository browser.