Changeset c9c94387 in rtems
- Timestamp:
- 08/13/96 19:05:27 (27 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 1d428a3c
- Parents:
- 76f03c6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/tests/psxtests/psx10/init.c
r76f03c6 rc9c94387 24 24 pthread_condattr_t attr; 25 25 int pshared; 26 pthread_cond_t cond = PTHREAD_COND_INITIALIZER; 26 pthread_cond_t cond; 27 struct timespec timeout; 27 28 28 29 puts( "\n\n*** POSIX TEST 10 ***" ); … … 90 91 assert( !status ); 91 92 93 /* initiailize the attribute for the rest of the test */ 94 92 95 puts( "Init: pthread_cond_init - attr" ); 93 96 status = pthread_cond_init( &Cond1_id, &attr ); 94 97 assert( !status ); 95 98 96 /* create a thread*/99 /* signal task1 with a condition variable */ 97 100 98 101 empty_line(); … … 100 103 status = pthread_create( &Task_id, NULL, Task_1, NULL ); 101 104 assert( !status ); 105 106 /* switch to task1 to allow it to wait for a condition variable */ 102 107 103 108 puts( "Init: sleep to switch to Task_1" ); … … 113 118 assert( !status ); 114 119 120 /* switch to task1 and task2 to allow them to wait for broadcast signal */ 121 115 122 puts( "Init: sleep - switch to Task_1 and Task_2" ); 116 123 sleep( 1 ); 124 125 /* broadcast a condition variable to task1 and task2 */ 117 126 118 127 puts( "Init: pthread_cond_broadcast" ); … … 121 130 122 131 puts( "Init: sleep - switch to Task_1" ); 123 sleep( 1);132 sleep( 0 ); 124 133 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" ); 125 150 /* exit this thread */ 126 151 -
testsuites/psxtests/psx10/init.c
r76f03c6 rc9c94387 24 24 pthread_condattr_t attr; 25 25 int pshared; 26 pthread_cond_t cond = PTHREAD_COND_INITIALIZER; 26 pthread_cond_t cond; 27 struct timespec timeout; 27 28 28 29 puts( "\n\n*** POSIX TEST 10 ***" ); … … 90 91 assert( !status ); 91 92 93 /* initiailize the attribute for the rest of the test */ 94 92 95 puts( "Init: pthread_cond_init - attr" ); 93 96 status = pthread_cond_init( &Cond1_id, &attr ); 94 97 assert( !status ); 95 98 96 /* create a thread*/99 /* signal task1 with a condition variable */ 97 100 98 101 empty_line(); … … 100 103 status = pthread_create( &Task_id, NULL, Task_1, NULL ); 101 104 assert( !status ); 105 106 /* switch to task1 to allow it to wait for a condition variable */ 102 107 103 108 puts( "Init: sleep to switch to Task_1" ); … … 113 118 assert( !status ); 114 119 120 /* switch to task1 and task2 to allow them to wait for broadcast signal */ 121 115 122 puts( "Init: sleep - switch to Task_1 and Task_2" ); 116 123 sleep( 1 ); 124 125 /* broadcast a condition variable to task1 and task2 */ 117 126 118 127 puts( "Init: pthread_cond_broadcast" ); … … 121 130 122 131 puts( "Init: sleep - switch to Task_1" ); 123 sleep( 1);132 sleep( 0 ); 124 133 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" ); 125 150 /* exit this thread */ 126 151
Note: See TracChangeset
for help on using the changeset viewer.