Changeset 76f03c6 in rtems


Ignore:
Timestamp:
08/13/96 19:03:29 (26 years ago)
Author:
Mark Johannes <Mark.Johannes@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
c9c94387
Parents:
b2e8026
Message:

_POSIX_Condition_variables_Wait_support: fixed the timeout sequence.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/src/cond.c

    rb2e8026 r76f03c6  
    201201  the_cond->process_shared  = the_attr->process_shared;
    202202
    203   the_cond->Mutex = (unsigned32) NULL;
     203  the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
    204204
    205205/* XXX some more initialization might need to go here */
     
    317317        the_thread = _Thread_queue_Dequeue( &the_cond->Wait_queue );
    318318        if ( !the_thread )
    319           the_cond->Mutex = (unsigned32) NULL;
     319          the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
    320320      } while ( is_broadcast && the_thread );
     321
     322      _Thread_Enable_dispatch();
     323
    321324      return 0;
    322325  }
     
    376379    case OBJECTS_LOCAL:
    377380 
    378       if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) )
     381      if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) ) {
     382        _Thread_Enable_dispatch();
    379383        return EINVAL;
     384      }
     385 
     386      the_cond->Mutex = *mutex;
    380387 
    381388      status = pthread_mutex_unlock( mutex );
    382       if ( status )
     389      if ( status ) {
     390        _Thread_Enable_dispatch();
    383391        return status;
    384  
    385       the_cond->Mutex = *mutex;
     392      }
    386393 
    387394      _Thread_queue_Enter_critical_section( &the_cond->Wait_queue );
    388 
    389       _Thread_queue_Enqueue( &the_cond->Wait_queue, 0 );
     395      _Thread_Executing->Wait.return_code = 0;
     396      _Thread_Executing->Wait.queue       = &the_cond->Wait_queue;
     397      _Thread_Executing->Wait.id          = *cond;
     398
     399      _Thread_queue_Enqueue( &the_cond->Wait_queue, timeout );
    390400
    391401      _Thread_Enable_dispatch();
     402
     403      /*
     404       *  Switch ourself out because we blocked as a result of the
     405       *  _Thread_queue_Enqueue.
     406       */
     407
     408      if ( _Thread_Executing->Wait.return_code )
     409        return _Thread_Executing->Wait.return_code;
    392410
    393411      status = pthread_mutex_lock( mutex );
  • cpukit/posix/src/cond.c

    rb2e8026 r76f03c6  
    201201  the_cond->process_shared  = the_attr->process_shared;
    202202
    203   the_cond->Mutex = (unsigned32) NULL;
     203  the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
    204204
    205205/* XXX some more initialization might need to go here */
     
    317317        the_thread = _Thread_queue_Dequeue( &the_cond->Wait_queue );
    318318        if ( !the_thread )
    319           the_cond->Mutex = (unsigned32) NULL;
     319          the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
    320320      } while ( is_broadcast && the_thread );
     321
     322      _Thread_Enable_dispatch();
     323
    321324      return 0;
    322325  }
     
    376379    case OBJECTS_LOCAL:
    377380 
    378       if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) )
     381      if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) ) {
     382        _Thread_Enable_dispatch();
    379383        return EINVAL;
     384      }
     385 
     386      the_cond->Mutex = *mutex;
    380387 
    381388      status = pthread_mutex_unlock( mutex );
    382       if ( status )
     389      if ( status ) {
     390        _Thread_Enable_dispatch();
    383391        return status;
    384  
    385       the_cond->Mutex = *mutex;
     392      }
    386393 
    387394      _Thread_queue_Enter_critical_section( &the_cond->Wait_queue );
    388 
    389       _Thread_queue_Enqueue( &the_cond->Wait_queue, 0 );
     395      _Thread_Executing->Wait.return_code = 0;
     396      _Thread_Executing->Wait.queue       = &the_cond->Wait_queue;
     397      _Thread_Executing->Wait.id          = *cond;
     398
     399      _Thread_queue_Enqueue( &the_cond->Wait_queue, timeout );
    390400
    391401      _Thread_Enable_dispatch();
     402
     403      /*
     404       *  Switch ourself out because we blocked as a result of the
     405       *  _Thread_queue_Enqueue.
     406       */
     407
     408      if ( _Thread_Executing->Wait.return_code )
     409        return _Thread_Executing->Wait.return_code;
    392410
    393411      status = pthread_mutex_lock( mutex );
Note: See TracChangeset for help on using the changeset viewer.