Changeset 1ff7e19 in rtems


Ignore:
Timestamp:
Jan 29, 2008, 6:59:00 PM (12 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.10, 4.11, 4.9, master
Children:
01618cc
Parents:
b7bc1d1
Message:

2008-01-29 Jennifer Averett <jennifer.averett@…>

  • score/src/corerwlockrelease.c, score/src/coresemseize.c: Changed switch statements to if statements.
Location:
cpukit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rb7bc1d1 r1ff7e19  
     12008-01-29      Jennifer Averett <jennifer.averett@OARcorp.com>
     2
     3        * score/src/corerwlockrelease.c, score/src/coresemseize.c: Changed
     4        switch statements to if statements.
     5
    162008-01-29      Joel Sherrill <joel.sherrill@OARcorp.com>
    27
  • cpukit/score/src/corerwlockrelease.c

    rb7bc1d1 r1ff7e19  
    5050
    5151  _ISR_Disable( level );
    52     switch ( the_rwlock->current_state ) {
    53       case CORE_RWLOCK_UNLOCKED:
    54         _ISR_Enable( level );
    55         executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
    56         return CORE_RWLOCK_SUCCESSFUL;
    57 
    58       case CORE_RWLOCK_LOCKED_FOR_READING:
     52    if ( the_rwlock->current_state == CORE_RWLOCK_UNLOCKED){
     53      _ISR_Enable( level );
     54      executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
     55      return CORE_RWLOCK_SUCCESSFUL;
     56    }
     57    if ( the_rwlock->current_state == CORE_RWLOCK_LOCKED_FOR_READING ) {
    5958        the_rwlock->number_of_readers -= 1;
    6059        if ( the_rwlock->number_of_readers != 0 ) {
     
    6362          return CORE_RWLOCK_SUCCESSFUL;
    6463        }
    65         executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
    66         break;
    67       case CORE_RWLOCK_LOCKED_FOR_WRITING:
    68         executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
    69         break;
    70     }
     64    }       
     65
     66    /* CORE_RWLOCK_LOCKED_FOR_WRITING or READING with readers */
     67    executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
    7168
    7269    /*
     
    7572     */
    7673    the_rwlock->current_state = CORE_RWLOCK_UNLOCKED;
    77     _ISR_Enable( level );
     74  _ISR_Enable( level );
    7875
    79     next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue );
     76  next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue );
    8077   
    81     if ( next ) {
    82       if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
    83         the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
     78  if ( next ) {
     79    if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
     80      the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
     81      return CORE_RWLOCK_SUCCESSFUL;
     82    }
     83
     84    /*
     85     * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING
     86     */
     87    the_rwlock->number_of_readers += 1;
     88    the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING;
     89
     90    /*
     91     * Now see if more readers can be let go.
     92     */
     93    while ( 1 ) {
     94      next = _Thread_queue_First( &the_rwlock->Wait_queue );
     95      if ( !next || 
     96           next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE )
    8497        return CORE_RWLOCK_SUCCESSFUL;
    85       }
     98      the_rwlock->number_of_readers += 1;
     99      _Thread_queue_Extract( &the_rwlock->Wait_queue, next );
     100    }
     101  }
    86102
    87       /*
    88        * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING
    89        */
    90       the_rwlock->number_of_readers += 1;
    91       the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING;
    92 
    93       /*
    94        * Now see if more readers can be let go.
    95        */
    96       while ( 1 ) {
    97         next = _Thread_queue_First( &the_rwlock->Wait_queue );
    98         if ( !next || 
    99              next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE )
    100           return CORE_RWLOCK_SUCCESSFUL;
    101         the_rwlock->number_of_readers += 1;
    102         _Thread_queue_Extract( &the_rwlock->Wait_queue, next );
    103       }
    104     }
    105103  /* indentation is to match _ISR_Disable at top */
    106104
  • cpukit/score/src/coresemseize.c

    rb7bc1d1 r1ff7e19  
    7070  }
    7171
    72   switch ( wait ) {
    73     case CORE_SEMAPHORE_NO_WAIT:
     72  if ( wait == CORE_SEMAPHORE_NO_WAIT ) {
    7473      _ISR_Enable( level );
    7574      executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
    7675      return;
    77     case CORE_SEMAPHORE_BAD_TIMEOUT:
     76  }
     77  if (wait == CORE_SEMAPHORE_BAD_TIMEOUT ) {
    7878      _ISR_Enable( level );
    7979      executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
    8080      return;
    81     case CORE_SEMAPHORE_BLOCK_FOREVER:
    82     case CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT:
     81  }
     82  if (( wait == CORE_SEMAPHORE_BLOCK_FOREVER) ||
     83      ( wait == CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT ) ) {
    8384      _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
    8485      executing->Wait.queue          = &the_semaphore->Wait_queue;
     
    8687      _ISR_Enable( level );
    8788      _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
    88       break;
    8989  }
    9090
Note: See TracChangeset for help on using the changeset viewer.