Changeset d50acdbb in rtems for cpukit/sapi


Ignore:
Timestamp:
Mar 10, 2014, 7:25:32 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
28779c7
Parents:
ae88aa7
git-author:
Sebastian Huber <sebastian.huber@…> (03/10/14 07:25:32)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/11/14 09:58:09)
Message:

score: Add local context to SMP lock API

Add a local context structure to the SMP lock API for acquire and
release pairs. This context can be used to store the ISR level and
profiling information. It may be later used to enable more
sophisticated lock algorithms, e.g. MCS locks.

There is only one lock that cannot be used with a local context. This
is the per-CPU lock since here we would have to transfer the local
context through a context switch which is very complicated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/src/chainsmp.c

    rae88aa7 rd50acdbb  
    2525static SMP_lock_Control chain_lock = SMP_LOCK_INITIALIZER;
    2626
    27 static void chain_acquire( ISR_Level *level )
     27static void chain_acquire( SMP_lock_Context *lock_context )
    2828{
    29   _SMP_lock_ISR_disable_and_acquire( &chain_lock, *level );
     29  _SMP_lock_ISR_disable_and_acquire( &chain_lock, lock_context );
    3030}
    3131
    32 static void chain_release( ISR_Level *level )
     32static void chain_release( SMP_lock_Context *lock_context )
    3333{
    34   _SMP_lock_Release_and_ISR_enable( &chain_lock, *level );
     34  _SMP_lock_Release_and_ISR_enable( &chain_lock, lock_context );
    3535}
    3636
    3737void rtems_chain_extract( rtems_chain_node *node )
    3838{
    39   ISR_Level level;
     39  SMP_lock_Context lock_context;
    4040
    41   chain_acquire( &level );
     41  chain_acquire( &lock_context );
    4242  _Chain_Extract_unprotected( node );
    43   chain_release( &level );
     43  chain_release( &lock_context );
    4444}
    4545
     
    4747{
    4848  rtems_chain_node *node;
    49   ISR_Level level;
     49  SMP_lock_Context lock_context;
    5050
    51   chain_acquire( &level );
     51  chain_acquire( &lock_context );
    5252  node = _Chain_Get_unprotected( chain );
    53   chain_release( &level );
     53  chain_release( &lock_context );
    5454
    5555  return node;
     
    5858void rtems_chain_insert( rtems_chain_node *after_node, rtems_chain_node *node )
    5959{
    60   ISR_Level level;
     60  SMP_lock_Context lock_context;
    6161
    62   chain_acquire( &level );
     62  chain_acquire( &lock_context );
    6363  _Chain_Insert_unprotected( after_node, node );
    64   chain_release( &level );
     64  chain_release( &lock_context );
    6565}
    6666
     
    7070)
    7171{
    72   ISR_Level level;
     72  SMP_lock_Context lock_context;
    7373
    74   chain_acquire( &level );
     74  chain_acquire( &lock_context );
    7575  _Chain_Append_unprotected( chain, node );
    76   chain_release( &level );
     76  chain_release( &lock_context );
    7777}
    7878
     
    8282)
    8383{
    84   ISR_Level level;
     84  SMP_lock_Context lock_context;
    8585
    86   chain_acquire( &level );
     86  chain_acquire( &lock_context );
    8787  _Chain_Prepend_unprotected( chain, node );
    88   chain_release( &level );
     88  chain_release( &lock_context );
    8989}
    9090
     
    9595{
    9696  bool was_empty;
    97   ISR_Level level;
     97  SMP_lock_Context lock_context;
    9898
    99   chain_acquire( &level );
     99  chain_acquire( &lock_context );
    100100  was_empty = _Chain_Append_with_empty_check_unprotected( chain, node );
    101   chain_release( &level );
     101  chain_release( &lock_context );
    102102
    103103  return was_empty;
     
    110110{
    111111  bool was_empty;
    112   ISR_Level level;
     112  SMP_lock_Context lock_context;
    113113
    114   chain_acquire( &level );
     114  chain_acquire( &lock_context );
    115115  was_empty = _Chain_Prepend_with_empty_check_unprotected( chain, node );
    116   chain_release( &level );
     116  chain_release( &lock_context );
    117117
    118118  return was_empty;
     
    125125{
    126126  bool is_empty_now;
    127   ISR_Level level;
     127  SMP_lock_Context lock_context;
    128128
    129   chain_acquire( &level );
     129  chain_acquire( &lock_context );
    130130  is_empty_now = _Chain_Get_with_empty_check_unprotected( chain, node );
    131   chain_release( &level );
     131  chain_release( &lock_context );
    132132
    133133  return is_empty_now;
Note: See TracChangeset for help on using the changeset viewer.