Changeset 7f6a24ab in rtems for cpukit/score


Ignore:
Timestamp:
08/28/95 15:30:29 (27 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
5072b07
Parents:
5250ff39
Message:

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

Location:
cpukit/score
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/mppkt.h

    r5250ff39 r7f6a24ab  
    6565  Objects_Id              id;
    6666  Objects_Id              source_tid;
    67   rtems_task_priority     source_priority;
     67  Priority_Control        source_priority;
    6868  rtems_status_code       return_code;
    6969  unsigned32              length;
  • cpukit/score/include/rtems/score/object.h

    r5250ff39 r7f6a24ab  
    350350
    351351/*
     352 *  _Objects_Get_information
     353 *
     354 *  DESCRIPTION:
     355 *
     356 *  Returns the information control block for the class of objects
     357 *  corresponding to this id.
     358 */
     359
     360Objects_Information *_Objects_Get_information(
     361  Objects_Id  id
     362);
     363 
     364/*
    352365 *  _Objects_Build_id
    353366 *
     
    405418
    406419/*
     420 *  _Objects_Is_class_valid
     421 *
     422 *  DESCRIPTION:
     423 *
     424 *  This function returns TRUE if the class is valid.
     425 *
     426 */
     427 
     428STATIC INLINE boolean _Objects_Is_class_valid(
     429  Objects_Classes the_class
     430);
     431
     432/*
    407433 *  _Objects_Is_local_node
    408434 *
  • cpukit/score/include/rtems/score/objectmp.h

    r5250ff39 r7f6a24ab  
    8282);
    8383
     84/*PAGE
     85 *
     86 *  _Objects_MP_Open
     87 *
     88 *  DESCRIPTION:
     89 *
     90 *  This routine place the specified global object in the
     91 *  specified information table. 
     92 */
     93 
     94void _Objects_MP_Open (
     95  Objects_Information *information,
     96  Objects_MP_Control  *the_global_object,
     97  unsigned32           the_name,      /* XXX -- wrong for variable */
     98  Objects_Id           the_id
     99);
     100
    84101/*
    85  *  _Objects_MP_Open
     102 *  _Objects_MP_Allocate_and_open
    86103 *
    87104 *  DESCRIPTION:
     
    93110 */
    94111
    95 boolean _Objects_MP_Open (
     112boolean _Objects_MP_Allocate_and_open (
    96113  Objects_Information *information,
    97114  unsigned32           the_name,     /* XXX -- wrong for variable length */
  • cpukit/score/include/rtems/score/priority.h

    r5250ff39 r7f6a24ab  
    3030 */
    3131
    32 typedef unsigned32 rtems_task_priority;
     32typedef unsigned32 Priority_Control;
    3333
    3434#define RTEMS_MINIMUM_PRIORITY      1         /* highest thread priority */
     
    9393
    9494STATIC INLINE boolean _Priority_Is_valid (
    95   rtems_task_priority the_priority
     95  Priority_Control the_priority
    9696);
    9797
     
    105105
    106106STATIC INLINE unsigned32 _Priority_Major (
    107   rtems_task_priority the_priority
     107  Priority_Control the_priority
    108108);
    109109
     
    117117
    118118STATIC INLINE unsigned32 _Priority_Minor (
    119   rtems_task_priority the_priority
     119  Priority_Control the_priority
    120120);
    121121
     
    156156 */
    157157
    158 STATIC INLINE rtems_task_priority _Priority_Get_highest( void );
     158STATIC INLINE Priority_Control _Priority_Get_highest( void );
    159159
    160160/*
     
    170170STATIC INLINE void _Priority_Initialize_information(
    171171  Priority_Information *the_priority_map,
    172   rtems_task_priority      new_priority
     172  Priority_Control      new_priority
    173173);
    174174
     
    183183
    184184STATIC INLINE boolean _Priority_Is_group_empty (
    185   rtems_task_priority      the_priority
     185  Priority_Control      the_priority
    186186);
    187187
  • cpukit/score/include/rtems/score/thread.h

    r5250ff39 r7f6a24ab  
    8787                   );
    8888
    89 typedef Thread ( *Thread_Entry )(
    90                       Thread_Argument
    91                    );
     89typedef Thread ( *Thread_Entry )( );
    9290
    9391/*
     
    9694 */
    9795
     96typedef enum {
     97  THREAD_START_NUMERIC,
     98  THREAD_START_POINTER,
     99  THREAD_START_BOTH_POINTER_FIRST,
     100  THREAD_START_BOTH_NUMERIC_FIRST
     101} Thread_Start_types;
     102
    98103typedef struct {
    99104  Thread_Entry         entry_point;      /* starting thread address         */
    100   unsigned32           initial_argument; /* initial argument                */
    101   rtems_mode           initial_modes;    /* initial mode                    */
    102   rtems_task_priority  initial_priority; /* initial priority                */
     105  Thread_Start_types   prototype;        /* how task is invoked             */
     106  void                *pointer_argument; /* pointer argument                */
     107  unsigned32           numeric_argument; /* numeric argument                */
     108  Modes_Control        initial_modes;    /* initial mode                    */
     109  Priority_Control     initial_priority; /* initial priority                */
     110  Stack_Control        Initial_stack;    /* stack information               */
    103111  void                *fp_context;       /* initial FP context area address */
    104   Stack_Control        Initial_stack;    /* stack information              */
     112  void                *stack;            /* initial FP context area address */
    105113}   Thread_Start_information;
    106114
     
    135143  Objects_Control          Object;
    136144  States_Control           current_state;
    137   rtems_task_priority      current_priority;
    138   rtems_task_priority      real_priority;
     145  Priority_Control         current_priority;
     146  Priority_Control         real_priority;
    139147  unsigned32               resource_count;
    140148  Thread_Wait_information  Wait;
     
    154162 */
    155163
     164/* XXX structure in wrong file .. API .. not core */
     165
     166typedef struct {
     167  boolean                   is_global;
     168  unsigned32                Notepads[ RTEMS_NUMBER_NOTEPADS ];
     169  rtems_event_set           pending_events;
     170  rtems_event_set           events_out;
     171  ASR_Information           Signal;
     172}  RTEMS_API_Control;
     173
    156174typedef struct {
    157175  Objects_Control           Object;
    158176  States_Control            current_state;
    159   rtems_task_priority       current_priority;
    160   rtems_task_priority       real_priority;
     177  Priority_Control          current_priority;
     178  Priority_Control          real_priority;
    161179  unsigned32                resource_count;
    162180  Thread_Wait_information   Wait;
     
    166184  Chain_Control            *ready;
    167185  Priority_Information      Priority_map;
    168   rtems_event_set           pending_events;
    169   rtems_event_set           events_out;
    170186  Thread_Start_information  Start;
    171   ASR_Information           Signal;
    172   rtems_mode                current_modes;
    173   rtems_attribute           attribute_set;
     187  Modes_Control             current_modes;
    174188  Context_Control           Registers;
    175189  void                     *fp_context;
    176   unsigned32                Notepads[ RTEMS_NUMBER_NOTEPADS ];
     190  RTEMS_API_Control        *RTEMS_API;
    177191  void                     *extension;
    178192}   Thread_Control;
     
    304318
    305319void _Thread_Dispatch( void );
     320
     321/*
     322 *  _Thread_Initialize
     323 *
     324 *  DESCRIPTION:
     325 *
     326 *  XXX
     327 */
     328
     329boolean _Thread_Initialize(
     330  Objects_Information *information,
     331  Thread_Control      *the_thread,
     332  void                *stack_area,    /* NULL if to be allocated */
     333  unsigned32           stack_size,    /* insure it is >= min */
     334  boolean              is_fp,         /* TRUE if thread uses FP */
     335  Priority_Control     priority,
     336  Modes_Control        mode,
     337  Objects_Name         name
     338 
     339);
     340
     341/*
     342 *  _Thread_Start
     343 *
     344 *  DESCRIPTION:
     345 *
     346 *  XXX
     347 */
     348 
     349boolean _Thread_Start(
     350  Thread_Control           *the_thread,
     351  Thread_Start_types        the_prototype,
     352  void                     *entry_point,
     353  void                     *pointer_argument,
     354  unsigned32                numeric_argument
     355);
     356
     357/*
     358 *  _Thread_Restart
     359 *
     360 *  DESCRIPTION:
     361 *
     362 *  XXX
     363 */
     364 
     365/* XXX multiple task arg profiles */
     366 
     367boolean _Thread_Restart(
     368  Thread_Control           *the_thread,
     369  void                     *pointer_argument,
     370  unsigned32                numeric_argument
     371);
     372
     373/*
     374 *  _Thread_Close
     375 *
     376 *  DESCRIPTION:
     377 *
     378 *  XXX
     379 */
     380 
     381void _Thread_Close(
     382  Objects_Information  *information,
     383  Thread_Control       *the_thread
     384);
    306385
    307386/*
     
    494573void _Thread_Change_priority (
    495574  Thread_Control   *the_thread,
    496   rtems_task_priority  new_priority
     575  Priority_Control  new_priority
    497576);
    498577
     
    508587void _Thread_Set_priority(
    509588  Thread_Control   *the_thread,
    510   rtems_task_priority  new_priority
     589  Priority_Control  new_priority
    511590);
    512591
     
    525604
    526605boolean _Thread_Change_mode(
    527   rtems_mode  new_mode_set,
    528   rtems_mode  mask,
    529   rtems_mode *old_mode_set
     606  Modes_Control  new_mode_set,
     607  Modes_Control  mask,
     608  Modes_Control *old_mode_set
    530609);
    531610
  • cpukit/score/include/rtems/score/threadq.h

    r5250ff39 r7f6a24ab  
    3636                 Thread_Control *
    3737             );
     38
     39/*
     40 *  The following type defines the callout used when a local task
     41 *  is extracted from a remote thread queue (i.e. it's proxy must
     42 *  extracted from the remote queue).
     43 */
     44 
     45typedef void ( *Thread_queue_Extract_callout )(
     46                 Thread_Control *
     47             );
     48
     49EXTERN Thread_queue_Extract_callout 
     50  _Thread_queue_Extract_table[ OBJECTS_CLASSES_LAST + 1 ];
    3851
    3952/*
     
    6376void _Thread_queue_Enqueue(
    6477  Thread_queue_Control *the_thread_queue,
    65   rtems_interval     timeout
     78  rtems_interval        timeout
    6679);
    6780
     
    7790void _Thread_queue_Extract(
    7891  Thread_queue_Control *the_thread_queue,
     92  Thread_Control       *the_thread
     93);
     94
     95/*
     96 *  _Thread_queue_Extract_with_proxy
     97 *
     98 *  DESCRIPTION:
     99 *
     100 *  This routine extracts the_thread from the_thread_queue
     101 *  and insures that if there is a proxy for this task on
     102 *  another node, it is also dealt with.
     103 */
     104 
     105boolean _Thread_queue_Extract_with_proxy(
    79106  Thread_Control       *the_thread
    80107);
     
    119146
    120147void _Thread_queue_Initialize(
    121   Thread_queue_Control *the_thread_queue,
    122   rtems_attribute    attribute_set,
    123   States_Control        state
     148  Thread_queue_Control         *the_thread_queue,
     149  Objects_Classes               the_class,
     150  Thread_queue_Disciplines      the_discipline,
     151  States_Control                state,
     152  Thread_queue_Extract_callout  proxy_extract_callout
    124153);
    125154
  • cpukit/score/include/rtems/score/tqdata.h

    r5250ff39 r7f6a24ab  
    3232
    3333typedef enum {
    34   THREAD_QUEUE_DATA_FIFO_DISCIPLINE,     /* RTEMS_FIFO queue discipline */
    35   THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE  /* RTEMS_PRIORITY queue discipline */
     34  THREAD_QUEUE_DISCIPLINE_FIFO,     /* RTEMS_FIFO queue discipline */
     35  THREAD_QUEUE_DISCIPLINE_PRIORITY  /* RTEMS_PRIORITY queue discipline */
    3636}   Thread_queue_Disciplines;
    3737
     
    6464
    6565STATIC INLINE unsigned32 _Thread_queue_Header_number (
    66   rtems_task_priority the_priority
     66  Priority_Control the_priority
    6767);
    6868
     
    7878
    7979STATIC INLINE boolean _Thread_queue_Is_reverse_search (
    80   rtems_task_priority the_priority
     80  Priority_Control the_priority
    8181);
    8282
  • cpukit/score/include/rtems/score/userext.h

    r5250ff39 r7f6a24ab  
    7070
    7171STATIC INLINE void _User_extensions_Add_set (
    72   User_extensions_Control       *the_extension,
    73   rtems_extensions_table *extension_table
     72  User_extensions_Control  *the_extension,
     73  rtems_extensions_table   *extension_table
    7474);
    7575
  • cpukit/score/inline/rtems/score/object.inl

    r5250ff39 r7f6a24ab  
    7373{
    7474  return (id >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS;
     75}
     76
     77/*PAGE
     78 *
     79 *  _Objects_Is_class_valid
     80 *
     81 */
     82 
     83STATIC INLINE boolean _Objects_Is_class_valid(
     84  Objects_Classes the_class
     85)
     86{
     87  return the_class <= OBJECTS_CLASSES_LAST;
    7588}
    7689
  • cpukit/score/inline/rtems/score/priority.inl

    r5250ff39 r7f6a24ab  
    4242
    4343STATIC INLINE boolean _Priority_Is_valid (
    44   rtems_task_priority the_priority
     44  Priority_Control the_priority
    4545)
    4646{
     
    5656
    5757STATIC INLINE unsigned32 _Priority_Major (
    58   rtems_task_priority the_priority
     58  Priority_Control the_priority
    5959)
    6060{
     
    6969
    7070STATIC INLINE unsigned32 _Priority_Minor (
    71   rtems_task_priority the_priority
     71  Priority_Control the_priority
    7272)
    7373{
     
    110110 */
    111111
    112 STATIC INLINE rtems_task_priority _Priority_Get_highest( void )
     112STATIC INLINE Priority_Control _Priority_Get_highest( void )
    113113{
    114114  Priority_Bit_map_control minor;
     
    130130STATIC INLINE void _Priority_Initialize_information(
    131131  Priority_Information *the_priority_map,
    132   rtems_task_priority      new_priority
     132  Priority_Control      new_priority
    133133)
    134134{
     
    159159
    160160STATIC INLINE boolean _Priority_Is_group_empty (
    161   rtems_task_priority      the_priority
     161  Priority_Control      the_priority
    162162)
    163163{
  • cpukit/score/inline/rtems/score/tqdata.inl

    r5250ff39 r7f6a24ab  
    2525
    2626STATIC INLINE unsigned32 _Thread_queue_Header_number (
    27   rtems_task_priority the_priority
     27  Priority_Control the_priority
    2828)
    2929{
     
    3838
    3939STATIC INLINE boolean _Thread_queue_Is_reverse_search (
    40   rtems_task_priority the_priority
     40  Priority_Control the_priority
    4141)
    4242{
  • cpukit/score/inline/rtems/score/userext.inl

    r5250ff39 r7f6a24ab  
    4242
    4343STATIC INLINE void _User_extensions_Add_set (
    44   User_extensions_Control       *the_extension,
    45   rtems_extensions_table *extension_table
     44  User_extensions_Control *the_extension,
     45  rtems_extensions_table  *extension_table
    4646)
    4747{
  • cpukit/score/macros/rtems/score/object.inl

    r5250ff39 r7f6a24ab  
    5555#define rtems_get_index( _id ) \
    5656  (((_id) >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS)
     57
     58/*PAGE
     59 *
     60 *  _Objects_Is_class_valid
     61 *
     62 */
     63 
     64#define _Objects_Is_class_valid( _the_class ) \
     65  ( (_the_class) <= OBJECTS_CLASSES_LAST )
    5766
    5867/*PAGE
  • cpukit/score/macros/rtems/score/thread.inl

    r5250ff39 r7f6a24ab  
    9494#define _Thread_Calculate_heir() \
    9595 { \
    96    rtems_task_priority  highest; \
     96   Priority_Control  highest; \
    9797   \
    9898   _Priority_Get_highest( highest ); \
  • cpukit/score/src/mpci.c

    r5250ff39 r7f6a24ab  
    3737  _Thread_queue_Initialize(
    3838    &_MPCI_Remote_blocked_threads,
    39     RTEMS_FIFO,
    40     STATES_WAITING_FOR_RPC_REPLY
     39    OBJECTS_NO_CLASS,
     40    THREAD_QUEUE_DISCIPLINE_FIFO,
     41    STATES_WAITING_FOR_RPC_REPLY,
     42    NULL
    4143  );
    4244}
  • cpukit/score/src/object.c

    r5250ff39 r7f6a24ab  
    477477    return 0;
    478478}
     479
     480/*PAGE
     481 *
     482 *  _Objects_Get_information
     483 *
     484 *  XXX
     485 */
     486 
     487Objects_Information *_Objects_Get_information(
     488  Objects_Id  id
     489)
     490{
     491  Objects_Classes  the_class;
     492
     493  the_class = rtems_get_class( id );
     494
     495  if ( !_Objects_Is_class_valid( the_class ) )
     496    return NULL;
     497
     498  return _Objects_Information_table[ the_class ];
     499}
     500
  • cpukit/score/src/objectmp.c

    r5250ff39 r7f6a24ab  
    5151 *
    5252 */
    53 
    54 boolean _Objects_MP_Open (
    55   Objects_Information *information,
     53 
     54void _Objects_MP_Open (
     55  Objects_Information *information,
     56  Objects_MP_Control  *the_global_object,
    5657  unsigned32           the_name,      /* XXX -- wrong for variable */
    57   Objects_Id           the_id,
    58   boolean              is_fatal_error
    59 )
    60 {
    61   Objects_MP_Control  *the_global_object;
    62 
    63   the_global_object = _Objects_MP_Allocate_global_object();
    64   if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
    65 
    66     if ( is_fatal_error == FALSE )
    67       return FALSE;
    68 
    69     rtems_fatal_error_occurred( RTEMS_TOO_MANY );
    70 
    71   }
    72 
     58  Objects_Id           the_id
     59)
     60{
    7361  the_global_object->Object.id = the_id;
    7462  the_global_object->name      = the_name;
    75 
     63 
    7664  _Chain_Prepend(
    7765    &information->global_table[ rtems_get_node( the_id ) ],
    7866    &the_global_object->Object.Node
    7967  );
     68
     69}
     70
     71/*PAGE
     72 *
     73 *  _Objects_MP_Allocate_and_open
     74 *
     75 */
     76
     77boolean _Objects_MP_Allocate_and_open (
     78  Objects_Information *information,
     79  unsigned32           the_name,      /* XXX -- wrong for variable */
     80  Objects_Id           the_id,
     81  boolean              is_fatal_error
     82)
     83{
     84  Objects_MP_Control  *the_global_object;
     85
     86  the_global_object = _Objects_MP_Allocate_global_object();
     87  if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
     88
     89    if ( is_fatal_error == FALSE )
     90      return FALSE;
     91
     92    rtems_fatal_error_occurred( RTEMS_TOO_MANY );
     93
     94  }
     95
     96  _Objects_MP_Open( information, the_global_object, the_name, the_id );
    8097
    8198  return TRUE;
  • cpukit/score/src/thread.c

    r5250ff39 r7f6a24ab  
    143143void _Thread_Dispatch( void )
    144144{
    145   Thread_Control  *executing;
    146   Thread_Control  *heir;
    147   ISR_Level               level;
     145  Thread_Control   *executing;
     146  Thread_Control   *heir;
     147  ISR_Level         level;
    148148  rtems_signal_set  signal_set;
    149   rtems_mode           previous_mode;
     149  Modes_Control     previous_mode;
    150150
    151151  executing   = _Thread_Executing;
     
    200200  _Thread_Dispatch_disable_level = 0;
    201201
    202   if ( _ASR_Are_signals_pending( &executing->Signal ) ) {
    203     signal_set                       = executing->Signal.signals_posted;
    204     executing->Signal.signals_posted = 0;
     202  if ( _ASR_Are_signals_pending( &executing->RTEMS_API->Signal ) ) {
     203    signal_set = executing->RTEMS_API->Signal.signals_posted;
     204    executing->RTEMS_API->Signal.signals_posted = 0;
    205205    _ISR_Enable( level );
    206206
    207     executing->Signal.nest_level += 1;
    208     if (_Thread_Change_mode( executing->Signal.mode_set,
     207    executing->RTEMS_API->Signal.nest_level += 1;
     208    if (_Thread_Change_mode( executing->RTEMS_API->Signal.mode_set,
    209209                                RTEMS_ALL_MODE_MASKS, &previous_mode ))
    210210        _Thread_Dispatch();
    211211
    212     (*executing->Signal.handler)( signal_set );
    213 
    214     executing->Signal.nest_level -= 1;
     212    (*executing->RTEMS_API->Signal.handler)( signal_set );
     213
     214    executing->RTEMS_API->Signal.nest_level -= 1;
    215215    if (_Thread_Change_mode( previous_mode,
    216216                                RTEMS_ALL_MODE_MASKS, &previous_mode ))
     
    219219  else
    220220    _ISR_Enable( level );
     221}
     222
     223/*PAGE
     224 *
     225 *  _Thread_Initialize
     226 *
     227 *  XXX
     228 */
     229
     230boolean _Thread_Initialize(
     231  Objects_Information *information,
     232  Thread_Control      *the_thread,
     233  void                *stack_area,    /* NULL if to be allocated */
     234  unsigned32           stack_size,    /* insure it is >= min */
     235  boolean              is_fp,         /* TRUE if thread uses FP */
     236  Priority_Control     priority,
     237  Modes_Control        mode,
     238  Objects_Name         name
     239 
     240)
     241{
     242  unsigned32           actual_stack_size;
     243  void                *stack;
     244  void                *fp_area;
     245
     246  /*
     247   *  Allocate and Initialize the stack for this thread.
     248   */
     249
     250  if ( !_Stack_Is_enough( stack_size ) )
     251    actual_stack_size = RTEMS_MINIMUM_STACK_SIZE;
     252  else
     253    actual_stack_size = stack_size;
     254
     255  actual_stack_size = _Stack_Adjust_size( actual_stack_size );
     256  stack             = stack_area;
     257
     258  if ( !stack ) {
     259    stack = _Workspace_Allocate( actual_stack_size );
     260 
     261    if ( !stack )
     262      return FALSE;
     263
     264    the_thread->Start.stack = stack;
     265  } else
     266    the_thread->Start.stack = NULL;
     267
     268  _Stack_Initialize(
     269     &the_thread->Start.Initial_stack,
     270     stack,
     271     actual_stack_size
     272  );
     273
     274  /*
     275   *  Allocate the floating point area for this thread
     276   */
     277 
     278  if ( is_fp ) {
     279
     280    fp_area = _Workspace_Allocate( CONTEXT_FP_SIZE );
     281    if ( !fp_area ) {
     282      (void) _Workspace_Free( stack );
     283      return FALSE;
     284    }
     285    fp_area = _Context_Fp_start( fp_area, 0 );
     286
     287  } else
     288    fp_area = NULL;
     289
     290  the_thread->fp_context       = fp_area;
     291  the_thread->Start.fp_context = fp_area;
     292 
     293/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
     294  /*
     295   *  Allocate and initialize the RTEMS API specific information
     296   */
     297 
     298  the_thread->RTEMS_API = _Workspace_Allocate( sizeof( RTEMS_API_Control ) );
     299 
     300  if ( !the_thread->RTEMS_API ) {
     301/* XXX when in task_create
     302    _RTEMS_tasks_Free( the_thread );
     303    _Objects_MP_Free_global_object( the_global_object );
     304
     305    _Thread_Enable_dispatch();
     306    return( RTEMS_UNSATISFIED );
     307*/
     308      (void) _Workspace_Free( stack );
     309      (void) _Workspace_Free( fp_area );
     310      return FALSE;
     311 
     312  }
     313 
     314  the_thread->RTEMS_API->is_global              = FALSE;
     315  the_thread->RTEMS_API->pending_events         = EVENT_SETS_NONE_PENDING;
     316  _ASR_Initialize( &the_thread->RTEMS_API->Signal );
     317
     318  /* XXX should not be here .... */
     319 
     320/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
     321
     322  /*
     323   *  General initialization
     324   */
     325
     326  the_thread->current_state          = STATES_DORMANT;
     327  the_thread->current_modes          = mode;
     328  the_thread->resource_count         = 0;
     329  the_thread->real_priority          = priority;
     330  the_thread->Start.initial_priority = priority;
     331  the_thread->Start.initial_modes    = mode;
     332 
     333  _Thread_Set_priority( the_thread, priority );
     334
     335  /*
     336   *  Open the object
     337   */
     338
     339  _Objects_Open( information, &the_thread->Object, name );
     340
     341  /*
     342   *  Invoke create extensions
     343   */
     344
     345  _User_extensions_Task_create( the_thread );
     346  /* XXX if this fails ... */
     347
     348  return TRUE;
     349}
     350
     351/*
     352 *  _Thread_Start
     353 *
     354 *  DESCRIPTION:
     355 *
     356 *  XXX
     357 */
     358 
     359boolean _Thread_Start(
     360  Thread_Control       *the_thread,
     361  Thread_Start_types    the_prototype,
     362  void                 *entry_point,
     363  void                 *pointer_argument,
     364  unsigned32            numeric_argument
     365)
     366{
     367  if ( _States_Is_dormant( the_thread->current_state ) ) {
     368 
     369    the_thread->Start.entry_point      = entry_point;
     370   
     371    the_thread->Start.prototype        = the_prototype;
     372    the_thread->Start.pointer_argument = pointer_argument;
     373    the_thread->Start.numeric_argument = numeric_argument;
     374 
     375    _Thread_Load_environment( the_thread );
     376 
     377    _Thread_Ready( the_thread );
     378 
     379    _User_extensions_Task_start( the_thread );
     380 
     381    return TRUE;
     382  }
     383 
     384  return FALSE;
     385 
     386}
     387
     388/*
     389 *  _Thread_Restart
     390 *
     391 *  DESCRIPTION:
     392 *
     393 *  XXX
     394 */
     395 
     396boolean _Thread_Restart(
     397  Thread_Control      *the_thread,
     398  void                *pointer_argument,
     399  unsigned32           numeric_argument
     400)
     401{
     402  if ( !_States_Is_dormant( the_thread->current_state ) ) {
     403 
     404    _Thread_Set_transient( the_thread );
     405    the_thread->resource_count = 0;
     406    the_thread->current_modes  = the_thread->Start.initial_modes;
     407
     408    the_thread->Start.pointer_argument = pointer_argument;
     409    the_thread->Start.numeric_argument = numeric_argument;
     410 
     411    if ( !_Thread_queue_Extract_with_proxy( the_thread ) ) {
     412 
     413      if ( _Watchdog_Is_active( &the_thread->Timer ) )
     414        (void) _Watchdog_Remove( &the_thread->Timer );
     415    }
     416
     417    if ( the_thread->current_priority != the_thread->Start.initial_priority ) {
     418      the_thread->real_priority = the_thread->Start.initial_priority;
     419      _Thread_Set_priority( the_thread, the_thread->Start.initial_priority );
     420    }
     421 
     422    _Thread_Load_environment( the_thread );
     423 
     424    _Thread_Ready( the_thread );
     425 
     426    _User_extensions_Task_restart( the_thread );
     427 
     428    if ( _Thread_Is_executing ( the_thread ) )
     429      _Thread_Restart_self();
     430 
     431    return TRUE;
     432  }
     433 
     434  return FALSE;
     435}
     436
     437/*
     438 *  _Thread_Close
     439 *
     440 *  DESCRIPTION:
     441 *
     442 *  XXX
     443 */
     444 
     445void _Thread_Close(
     446  Objects_Information  *information,
     447  Thread_Control       *the_thread
     448)
     449{
     450  _Objects_Close( information, &the_thread->Object );
     451 
     452  _Thread_Set_state( the_thread, STATES_TRANSIENT );
     453 
     454  if ( !_Thread_queue_Extract_with_proxy( the_thread ) ) {
     455 
     456    if ( _Watchdog_Is_active( &the_thread->Timer ) )
     457      (void) _Watchdog_Remove( &the_thread->Timer );
     458  }
     459
     460  _User_extensions_Task_delete( the_thread );
     461 
     462#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
     463  if ( _Thread_Is_allocated_fp( the_thread ) )
     464    _Thread_Deallocate_fp();
     465#endif
     466  the_thread->fp_context = NULL;
     467
     468  (void) _Workspace_Free( the_thread->Start.fp_context );
     469
     470  if ( the_thread->Start.stack )
     471    (void) _Workspace_Free( the_thread->Start.stack );
    221472}
    222473
     
    596847  _Thread_Enable_dispatch();
    597848 
    598   (*executing->Start.entry_point)( executing->Start.initial_argument );
     849  switch (  executing->Start.prototype ) {
     850    case THREAD_START_NUMERIC:
     851      (*executing->Start.entry_point)( executing->Start.numeric_argument );
     852      break;
     853    case THREAD_START_POINTER:
     854      (*executing->Start.entry_point)( executing->Start.pointer_argument );
     855      break;
     856    case THREAD_START_BOTH_POINTER_FIRST:
     857      (*executing->Start.entry_point)(
     858        executing->Start.pointer_argument,
     859        executing->Start.numeric_argument
     860      );
     861      break;
     862    case THREAD_START_BOTH_NUMERIC_FIRST:
     863      (*executing->Start.entry_point)(
     864        executing->Start.numeric_argument,
     865        executing->Start.pointer_argument
     866      );
     867      break;
     868  }
    599869
    600870  _User_extensions_Task_exitted( executing );
     
    655925
    656926void _Thread_Change_priority(
    657   Thread_Control *the_thread,
    658   rtems_task_priority       new_priority
     927  Thread_Control   *the_thread,
     928  Priority_Control  new_priority
    659929)
    660930{
     
    705975
    706976void _Thread_Set_priority(
    707   Thread_Control *the_thread,
    708   rtems_task_priority       new_priority
     977  Thread_Control   *the_thread,
     978  Priority_Control  new_priority
    709979)
    710980{
     
    7361006
    7371007boolean _Thread_Change_mode(
    738   unsigned32  new_mode_set,
    739   unsigned32  mask,
    740   unsigned32 *old_mode_set
    741 )
    742 {
    743   rtems_mode   changed;
    744   rtems_mode   threads_new_mode_set;
     1008  Modes_Control  new_mode_set,
     1009  Modes_Control  mask,
     1010  Modes_Control *old_mode_set
     1011)
     1012{
     1013  Modes_Control   changed;
     1014  Modes_Control   threads_new_mode_set;
    7451015  Thread_Control *executing;
    7461016  boolean         need_dispatch;
     
    7551025
    7561026  if ( _Modes_Mask_changed( changed, RTEMS_ASR_MASK ) )
    757     _ASR_Swap_signals( &executing->Signal );
     1027    _ASR_Swap_signals( &executing->RTEMS_API->Signal );
    7581028
    7591029  executing->current_modes = threads_new_mode_set;
     
    7661036     _Context_Switch_necessary = TRUE;
    7671037
    768   else if ( !_ASR_Are_signals_pending( &executing->Signal ) )
     1038  else if ( !_ASR_Are_signals_pending( &executing->RTEMS_API->Signal ) )
    7691039
    7701040    need_dispatch = FALSE;
  • cpukit/score/src/threadq.c

    r5250ff39 r7f6a24ab  
    3131 *  Input parameters:
    3232 *    the_thread_queue - pointer to a threadq header
    33  *    attribute_set    - used to determine queueing discipline
     33 *    the_class        - class of the object to which this belongs
     34 *    discipline       - queueing discipline
    3435 *    state            - state of waiting threads
    3536 *
     
    3839
    3940void _Thread_queue_Initialize(
    40   Thread_queue_Control *the_thread_queue,
    41   rtems_attribute           attribute_set,
    42   States_Control               state
     41  Thread_queue_Control         *the_thread_queue,
     42  Objects_Classes               the_class,
     43  Thread_queue_Disciplines      the_discipline,
     44  States_Control                state,
     45  Thread_queue_Extract_callout  proxy_extract_callout
    4346)
    4447{
    4548  unsigned32 index;
    4649
    47   if ( _Attributes_Is_priority( attribute_set ) ) {
    48     the_thread_queue->discipline = THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE;
    49     for( index=0 ;
    50          index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ;
    51          index++)
    52       _Chain_Initialize_empty( &the_thread_queue->Queues.Priority[index] );
    53   }
    54   else {
    55     the_thread_queue->discipline = THREAD_QUEUE_DATA_FIFO_DISCIPLINE;
    56     _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
    57   }
    58 
    59   the_thread_queue->state = state;
     50  _Thread_queue_Extract_table[ the_class ] = proxy_extract_callout;
     51
     52  the_thread_queue->state      = state;
     53  the_thread_queue->discipline = the_discipline;
     54
     55  switch ( the_discipline ) {
     56    case THREAD_QUEUE_DISCIPLINE_FIFO:
     57      _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
     58      break;
     59    case THREAD_QUEUE_DISCIPLINE_PRIORITY:
     60      for( index=0 ;
     61           index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ;
     62           index++)
     63        _Chain_Initialize_empty( &the_thread_queue->Queues.Priority[index] );
     64      break;
     65  }
    6066
    6167}
     
    108114
    109115  switch( the_thread_queue->discipline ) {
    110     case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
     116    case THREAD_QUEUE_DISCIPLINE_FIFO:
    111117      _Thread_queue_Enqueue_fifo( the_thread_queue, the_thread, timeout );
    112118      break;
    113     case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
     119    case THREAD_QUEUE_DISCIPLINE_PRIORITY:
    114120      _Thread_queue_Enqueue_priority(
    115121         the_thread_queue, the_thread, timeout );
     
    145151
    146152  switch ( the_thread_queue->discipline ) {
    147     case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
     153    case THREAD_QUEUE_DISCIPLINE_FIFO:
    148154      the_thread = _Thread_queue_Dequeue_fifo( the_thread_queue );
    149155      break;
    150     case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
     156    case THREAD_QUEUE_DISCIPLINE_PRIORITY:
    151157      the_thread = _Thread_queue_Dequeue_priority( the_thread_queue );
    152158      break;
     
    172178/*PAGE
    173179 *
     180 *  _Thread_queue_Extract_with_proxy
     181 *
     182 *  This routine extracts the_thread from the_thread_queue
     183 *  and insures that if there is a proxy for this task on
     184 *  another node, it is also dealt with.
     185 *
     186 *  XXX
     187 */
     188 
     189boolean _Thread_queue_Extract_with_proxy(
     190  Thread_Control       *the_thread
     191)
     192{
     193  States_Control                state;
     194  Objects_Classes               the_class;
     195  Thread_queue_Extract_callout  proxy_extract_callout;
     196
     197  state = the_thread->current_state;
     198
     199  if ( _States_Is_waiting_on_thread_queue( state ) ) {
     200    if ( _States_Is_waiting_for_rpc_reply( state ) &&
     201         _States_Is_locally_blocked( state ) ) {
     202
     203      the_class = rtems_get_class( the_thread->Wait.id );
     204
     205      proxy_extract_callout = _Thread_queue_Extract_table[ the_class ];
     206
     207      if ( proxy_extract_callout )
     208        (*proxy_extract_callout)( the_thread );
     209    }
     210    _Thread_queue_Extract( the_thread->Wait.queue, the_thread );
     211
     212    return TRUE;
     213  }
     214  return FALSE;
     215}
     216
     217/*PAGE
     218 *
    174219 *  _Thread_queue_Extract
    175220 *
     
    192237{
    193238  switch ( the_thread_queue->discipline ) {
    194     case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
     239    case THREAD_QUEUE_DISCIPLINE_FIFO:
    195240      _Thread_queue_Extract_fifo( the_thread_queue, the_thread );
    196241      break;
    197     case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
     242    case THREAD_QUEUE_DISCIPLINE_PRIORITY:
    198243      _Thread_queue_Extract_priority( the_thread_queue, the_thread );
    199244      break;
     
    249294
    250295  switch ( the_thread_queue->discipline ) {
    251     case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
     296    case THREAD_QUEUE_DISCIPLINE_FIFO:
    252297      the_thread = _Thread_queue_First_fifo( the_thread_queue );
    253298      break;
    254     case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
     299    case THREAD_QUEUE_DISCIPLINE_PRIORITY:
    255300      the_thread = _Thread_queue_First_priority( the_thread_queue );
    256301      break;
     
    438483  if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
    439484    _ISR_Enable( level );
    440     _Thread_Unblock( the_thread );
    441485  } else {
    442486    _Watchdog_Deactivate( &the_thread->Timer );
    443487    _ISR_Enable( level );
    444488    (void) _Watchdog_Remove( &the_thread->Timer );
    445     _Thread_Unblock( the_thread );
    446   }
     489  }
     490
     491  _Thread_Unblock( the_thread );
    447492
    448493  if ( !_Objects_Is_local_id( the_thread->Object.id ) )
    449494    _Thread_MP_Free_proxy( the_thread );
     495 
    450496}
    451497
     
    499545)
    500546{
    501   rtems_task_priority       search_priority;
    502   Thread_Control *search_thread;
    503   ISR_Level              level;
    504   Chain_Control  *header;
    505   unsigned32             header_index;
    506   Chain_Node     *the_node;
    507   Chain_Node     *next_node;
    508   Chain_Node     *previous_node;
    509   Chain_Node     *search_node;
    510   rtems_task_priority       priority;
    511   States_Control         block_state;
     547  Priority_Control  search_priority;
     548  Thread_Control   *search_thread;
     549  ISR_Level         level;
     550  Chain_Control    *header;
     551  unsigned32        header_index;
     552  Chain_Node       *the_node;
     553  Chain_Node       *next_node;
     554  Chain_Node       *previous_node;
     555  Chain_Node       *search_node;
     556  Priority_Control  priority;
     557  States_Control    block_state;
    512558
    513559  _Chain_Initialize_empty( &the_thread->Wait.Block2n );
Note: See TracChangeset for help on using the changeset viewer.