Changeset 12aeaec6 in rtems


Ignore:
Timestamp:
Jul 6, 2000, 7:10:30 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
8a3278fc
Parents:
3b4413c0
Message:

The code that attempts to obtain a mutex has now been inlined. The
code remaining here now only blocks.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/src/coremutexseize.c

    r3b4413c0 r12aeaec6  
    2626/*PAGE
    2727 *
    28  *  _CORE_mutex_Seize
     28 *  _CORE_mutex_Seize (interrupt blocking support)
    2929 *
    30  *  This routine attempts to allocate a mutex to the calling thread.
     30 *  This routine blocks the caller thread after an attempt attempts to obtain
     31 *  the specified mutex has failed.
    3132 *
    3233 *  Input parameters:
    3334 *    the_mutex - pointer to mutex control block
    34  *    id        - id of object to wait on
    35  *    wait      - TRUE if wait is allowed, FALSE otherwise
    3635 *    timeout   - number of ticks to wait (0 means forever)
    37  *
    38  *  Output parameters:  NONE
    39  *
    40  *  INTERRUPT LATENCY:
    41  *    available
    42  *    wait
    4336 */
    4437
    45 void _CORE_mutex_Seize(
     38void _CORE_mutex_Seize_interrupt_blocking(
    4639  CORE_mutex_Control  *the_mutex,
    47   Objects_Id           id,
    48   boolean              wait,
    4940  Watchdog_Interval    timeout
    5041)
    5142{
    52   Thread_Control *executing;
    53   ISR_Level       level;
     43  Thread_Control   *executing;
    5444
    5545  executing = _Thread_Executing;
    56   switch ( the_mutex->Attributes.discipline ) {
    57     case CORE_MUTEX_DISCIPLINES_FIFO:
    58     case CORE_MUTEX_DISCIPLINES_PRIORITY:
    59     case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    60       break;
    61     case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    62       if ( executing->current_priority <
    63                               the_mutex->Attributes.priority_ceiling) {
    64         executing->Wait.return_code = CORE_MUTEX_STATUS_CEILING_VIOLATED;
    65         return;
    66       }
    67   }
    68   executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
    69   _ISR_Disable( level );
    70   if ( ! _CORE_mutex_Is_locked( the_mutex ) ) {
    71     the_mutex->lock       = CORE_MUTEX_LOCKED;
    72     the_mutex->holder     = executing;
    73     the_mutex->holder_id  = executing->Object.id;
    74     the_mutex->nest_count = 1;
    75     executing->resource_count++;
    76     _ISR_Enable( level );
    77     switch ( the_mutex->Attributes.discipline ) {
    78       case CORE_MUTEX_DISCIPLINES_FIFO:
    79       case CORE_MUTEX_DISCIPLINES_PRIORITY:
    80       case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    81         /* already the highest priority */
    82         break;
    83       case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    84       if ( the_mutex->Attributes.priority_ceiling <
    85                                            executing->current_priority ) {
    86         _Thread_Change_priority(
    87           the_mutex->holder,
    88           the_mutex->Attributes.priority_ceiling,
    89           FALSE
    90         );
    91       }
    92     }
    93     executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
    94     return;
    95   }
    96 
    97   if ( _Thread_Is_executing( the_mutex->holder ) ) {
    98     switch ( the_mutex->Attributes.lock_nesting_behavior ) {
    99       case CORE_MUTEX_NESTING_ACQUIRES:
    100         the_mutex->nest_count++;
    101         _ISR_Enable( level );
    102         return;
    103       case CORE_MUTEX_NESTING_IS_ERROR:
    104         executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
    105         _ISR_Enable( level );
    106         return;
    107       case CORE_MUTEX_NESTING_BLOCKS:
    108         break;
    109     }
    110   }
    111 
    112   if ( !wait ) {
    113     _ISR_Enable( level );
    114     executing->Wait.return_code = CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT;
    115     return;
    116   }
    117 
    118   _Thread_queue_Enter_critical_section( &the_mutex->Wait_queue );
    119   executing->Wait.queue = &the_mutex->Wait_queue;
    120   executing->Wait.id    = id;
    121   _ISR_Enable( level );
    122 
    12346  switch ( the_mutex->Attributes.discipline ) {
    12447    case CORE_MUTEX_DISCIPLINES_FIFO:
     
    13760  }
    13861
     62  the_mutex->blocked_count++;
    13963  _Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout );
    14064
     
    15781    }
    15882  }
     83  _Thread_Enable_dispatch();
    15984}
    160 
  • cpukit/score/src/coremutexseize.c

    r3b4413c0 r12aeaec6  
    2626/*PAGE
    2727 *
    28  *  _CORE_mutex_Seize
     28 *  _CORE_mutex_Seize (interrupt blocking support)
    2929 *
    30  *  This routine attempts to allocate a mutex to the calling thread.
     30 *  This routine blocks the caller thread after an attempt attempts to obtain
     31 *  the specified mutex has failed.
    3132 *
    3233 *  Input parameters:
    3334 *    the_mutex - pointer to mutex control block
    34  *    id        - id of object to wait on
    35  *    wait      - TRUE if wait is allowed, FALSE otherwise
    3635 *    timeout   - number of ticks to wait (0 means forever)
    37  *
    38  *  Output parameters:  NONE
    39  *
    40  *  INTERRUPT LATENCY:
    41  *    available
    42  *    wait
    4336 */
    4437
    45 void _CORE_mutex_Seize(
     38void _CORE_mutex_Seize_interrupt_blocking(
    4639  CORE_mutex_Control  *the_mutex,
    47   Objects_Id           id,
    48   boolean              wait,
    4940  Watchdog_Interval    timeout
    5041)
    5142{
    52   Thread_Control *executing;
    53   ISR_Level       level;
     43  Thread_Control   *executing;
    5444
    5545  executing = _Thread_Executing;
    56   switch ( the_mutex->Attributes.discipline ) {
    57     case CORE_MUTEX_DISCIPLINES_FIFO:
    58     case CORE_MUTEX_DISCIPLINES_PRIORITY:
    59     case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    60       break;
    61     case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    62       if ( executing->current_priority <
    63                               the_mutex->Attributes.priority_ceiling) {
    64         executing->Wait.return_code = CORE_MUTEX_STATUS_CEILING_VIOLATED;
    65         return;
    66       }
    67   }
    68   executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
    69   _ISR_Disable( level );
    70   if ( ! _CORE_mutex_Is_locked( the_mutex ) ) {
    71     the_mutex->lock       = CORE_MUTEX_LOCKED;
    72     the_mutex->holder     = executing;
    73     the_mutex->holder_id  = executing->Object.id;
    74     the_mutex->nest_count = 1;
    75     executing->resource_count++;
    76     _ISR_Enable( level );
    77     switch ( the_mutex->Attributes.discipline ) {
    78       case CORE_MUTEX_DISCIPLINES_FIFO:
    79       case CORE_MUTEX_DISCIPLINES_PRIORITY:
    80       case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    81         /* already the highest priority */
    82         break;
    83       case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    84       if ( the_mutex->Attributes.priority_ceiling <
    85                                            executing->current_priority ) {
    86         _Thread_Change_priority(
    87           the_mutex->holder,
    88           the_mutex->Attributes.priority_ceiling,
    89           FALSE
    90         );
    91       }
    92     }
    93     executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
    94     return;
    95   }
    96 
    97   if ( _Thread_Is_executing( the_mutex->holder ) ) {
    98     switch ( the_mutex->Attributes.lock_nesting_behavior ) {
    99       case CORE_MUTEX_NESTING_ACQUIRES:
    100         the_mutex->nest_count++;
    101         _ISR_Enable( level );
    102         return;
    103       case CORE_MUTEX_NESTING_IS_ERROR:
    104         executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
    105         _ISR_Enable( level );
    106         return;
    107       case CORE_MUTEX_NESTING_BLOCKS:
    108         break;
    109     }
    110   }
    111 
    112   if ( !wait ) {
    113     _ISR_Enable( level );
    114     executing->Wait.return_code = CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT;
    115     return;
    116   }
    117 
    118   _Thread_queue_Enter_critical_section( &the_mutex->Wait_queue );
    119   executing->Wait.queue = &the_mutex->Wait_queue;
    120   executing->Wait.id    = id;
    121   _ISR_Enable( level );
    122 
    12346  switch ( the_mutex->Attributes.discipline ) {
    12447    case CORE_MUTEX_DISCIPLINES_FIFO:
     
    13760  }
    13861
     62  the_mutex->blocked_count++;
    13963  _Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout );
    14064
     
    15781    }
    15882  }
     83  _Thread_Enable_dispatch();
    15984}
    160 
Note: See TracChangeset for help on using the changeset viewer.