Changeset 5b393fa5 in rtems


Ignore:
Timestamp:
Mar 1, 2015, 12:50:55 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
4c8a0ac
Parents:
43e1573c
git-author:
Sebastian Huber <sebastian.huber@…> (03/01/15 12:50:55)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/05/15 10:36:44)
Message:

score: Add thread acquire

Update #2273.

Location:
cpukit/score
Files:
2 edited

Legend:

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

    r43e1573c r5b393fa5  
    397397  Objects_Locations *location
    398398);
     399
     400/**
     401 * @brief Acquires a thread by its identifier.
     402 *
     403 * @see _Objects_Acquire().
     404 */
     405Thread_Control *_Thread_Acquire(
     406  Objects_Id         id,
     407  Objects_Locations *location,
     408  ISR_lock_Context  *lock_context
     409);
     410
     411/**
     412 * @brief Acquires the executing thread.
     413 *
     414 * @see _Objects_Acquire().
     415 */
     416Thread_Control *_Thread_Acquire_executing( ISR_lock_Context *lock_context );
    399417
    400418/**
  • cpukit/score/src/threadget.c

    r43e1573c r5b393fa5  
    2222#include <rtems/score/threadimpl.h>
    2323
    24 Thread_Control *_Thread_Get (
    25   Objects_Id         id,
    26   Objects_Locations *location
     24static Objects_Information *_Thread_Get_objects_information(
     25  Objects_Id id
    2726)
    2827{
     
    3029  uint32_t             the_class;
    3130  Objects_Information **api_information;
    32   Objects_Information *information;
    33   Thread_Control      *tp = (Thread_Control *) 0;
    34 
    35   if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
    36     _Thread_Disable_dispatch();
    37     *location = OBJECTS_LOCAL;
    38     tp = _Thread_Executing;
    39     goto done;
    40   }
    4131
    4232  the_api = _Objects_Get_API( id );
    4333  if ( !_Objects_Is_api_valid( the_api ) ) {
    44     *location = OBJECTS_ERROR;
    45     goto done;
     34    return NULL;
    4635  }
    4736
    4837  the_class = _Objects_Get_class( id );
    4938  if ( the_class != 1 ) {       /* threads are always first class :) */
    50     *location = OBJECTS_ERROR;
    51     goto done;
     39    return NULL;
    5240  }
    5341
     
    6048   */
    6149  if ( !api_information ) {
    62     *location = OBJECTS_ERROR;
    63     goto done;
     50    return NULL;
    6451  }
    6552
    66   information = api_information[ the_class ];
    67   if ( !information ) {
    68     *location = OBJECTS_ERROR;
    69     goto done;
     53  return api_information[ the_class ];
     54}
     55
     56Thread_Control *_Thread_Get(
     57  Objects_Id         id,
     58  Objects_Locations *location
     59)
     60{
     61  Objects_Information *information;
     62
     63  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
     64    _Thread_Disable_dispatch();
     65    *location = OBJECTS_LOCAL;
     66    return _Thread_Executing;
    7067  }
    7168
    72   tp = (Thread_Control *) _Objects_Get( information, id, location );
     69  information = _Thread_Get_objects_information( id );
     70  if ( information == NULL ) {
     71    *location = OBJECTS_ERROR;
     72    return NULL;
     73  }
    7374
    74 done:
    75   return tp;
     75  return (Thread_Control *) _Objects_Get( information, id, location );
    7676}
    7777
     78Thread_Control *_Thread_Acquire_executing( ISR_lock_Context *lock_context )
     79{
     80  Thread_Control *executing;
     81
     82#if defined(RTEMS_SMP)
     83  _ISR_Disable_without_giant( lock_context->Lock_context.isr_level );
     84#else
     85  _ISR_Disable( lock_context->isr_level );
     86#endif
     87  executing = _Thread_Executing;
     88  _ISR_lock_Acquire( &executing->Object.Lock, lock_context );
     89
     90  return executing;
     91}
     92
     93Thread_Control *_Thread_Acquire(
     94  Objects_Id         id,
     95  Objects_Locations *location,
     96  ISR_lock_Context  *lock_context
     97)
     98{
     99  Objects_Information *information;
     100
     101  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
     102    *location = OBJECTS_LOCAL;
     103    return _Thread_Acquire_executing( lock_context );
     104  }
     105
     106  information = _Thread_Get_objects_information( id );
     107  if ( information == NULL ) {
     108    *location = OBJECTS_ERROR;
     109    return NULL;
     110  }
     111
     112  return (Thread_Control *)
     113    _Objects_Acquire( information, id, location, lock_context );
     114}
Note: See TracChangeset for help on using the changeset viewer.