Changeset c9c94387 in rtems


Ignore:
Timestamp:
08/13/96 19:05:27 (27 years ago)
Author:
Mark Johannes <Mark.Johannes@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
1d428a3c
Parents:
76f03c6
Message:

Init.c: added timewait case, added broadcast case

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/psxtests/psx10/init.c

    r76f03c6 rc9c94387  
    2424  pthread_condattr_t  attr;
    2525  int                 pshared;
    26   pthread_cond_t      cond = PTHREAD_COND_INITIALIZER;
     26  pthread_cond_t      cond;
     27  struct timespec     timeout;
    2728
    2829  puts( "\n\n*** POSIX TEST 10 ***" );
     
    9091  assert( !status );
    9192
     93/* initiailize the attribute for the rest of the test */
     94
    9295  puts( "Init: pthread_cond_init - attr" );
    9396  status = pthread_cond_init( &Cond1_id, &attr );
    9497  assert( !status );
    9598
    96   /* create a thread */
     99/* signal task1 with a condition variable */
    97100
    98101  empty_line();
     
    100103  status = pthread_create( &Task_id, NULL, Task_1, NULL );
    101104  assert( !status );
     105
     106/* switch to task1 to allow it to wait for a condition variable */
    102107
    103108  puts( "Init: sleep to switch to Task_1" );
     
    113118  assert( !status );
    114119
     120/* switch to task1 and task2 to allow them to wait for broadcast signal */
     121
    115122  puts( "Init: sleep - switch to Task_1 and Task_2" );
    116123  sleep( 1 );
     124
     125/* broadcast a condition variable to task1 and task2 */
    117126
    118127  puts( "Init: pthread_cond_broadcast" );
     
    121130
    122131  puts( "Init: sleep - switch to Task_1" );
    123   sleep( 1 );
     132  sleep( 0 );
    124133
     134/* timedwait case - timeout */
     135
     136  status = pthread_mutex_lock( &Mutex_id );
     137  assert( !status );
     138
     139/* set timeout to 3 seconds */
     140
     141  timeout.tv_sec = 3;
     142
     143  puts( "Init: pthread_cond_timedwait for 3 seconds" );
     144  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
     145  if ( status != ETIMEDOUT )
     146    printf( "status = %d\n", status );
     147  assert( status == ETIMEDOUT );
     148
     149  puts( "Init: timedout on pthread_cond_timedwait release mutex" );
    125150  /* exit this thread */
    126151
  • testsuites/psxtests/psx10/init.c

    r76f03c6 rc9c94387  
    2424  pthread_condattr_t  attr;
    2525  int                 pshared;
    26   pthread_cond_t      cond = PTHREAD_COND_INITIALIZER;
     26  pthread_cond_t      cond;
     27  struct timespec     timeout;
    2728
    2829  puts( "\n\n*** POSIX TEST 10 ***" );
     
    9091  assert( !status );
    9192
     93/* initiailize the attribute for the rest of the test */
     94
    9295  puts( "Init: pthread_cond_init - attr" );
    9396  status = pthread_cond_init( &Cond1_id, &attr );
    9497  assert( !status );
    9598
    96   /* create a thread */
     99/* signal task1 with a condition variable */
    97100
    98101  empty_line();
     
    100103  status = pthread_create( &Task_id, NULL, Task_1, NULL );
    101104  assert( !status );
     105
     106/* switch to task1 to allow it to wait for a condition variable */
    102107
    103108  puts( "Init: sleep to switch to Task_1" );
     
    113118  assert( !status );
    114119
     120/* switch to task1 and task2 to allow them to wait for broadcast signal */
     121
    115122  puts( "Init: sleep - switch to Task_1 and Task_2" );
    116123  sleep( 1 );
     124
     125/* broadcast a condition variable to task1 and task2 */
    117126
    118127  puts( "Init: pthread_cond_broadcast" );
     
    121130
    122131  puts( "Init: sleep - switch to Task_1" );
    123   sleep( 1 );
     132  sleep( 0 );
    124133
     134/* timedwait case - timeout */
     135
     136  status = pthread_mutex_lock( &Mutex_id );
     137  assert( !status );
     138
     139/* set timeout to 3 seconds */
     140
     141  timeout.tv_sec = 3;
     142
     143  puts( "Init: pthread_cond_timedwait for 3 seconds" );
     144  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
     145  if ( status != ETIMEDOUT )
     146    printf( "status = %d\n", status );
     147  assert( status == ETIMEDOUT );
     148
     149  puts( "Init: timedout on pthread_cond_timedwait release mutex" );
    125150  /* exit this thread */
    126151
Note: See TracChangeset for help on using the changeset viewer.