summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorMark Johannes <Mark.Johannes@OARcorp.com>1996-08-13 19:05:27 +0000
committerMark Johannes <Mark.Johannes@OARcorp.com>1996-08-13 19:05:27 +0000
commitc9c94387d13379aeec9e7cd0f92c810b7edb7813 (patch)
tree7cd281c43da726c5dc88bf1ea7d0bfe4ec16b551 /testsuites/psxtests
parent_POSIX_Condition_variables_Wait_support: fixed the timeout sequence. (diff)
downloadrtems-c9c94387d13379aeec9e7cd0f92c810b7edb7813.tar.bz2
Init.c: added timewait case, added broadcast case
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/psx10/init.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/testsuites/psxtests/psx10/init.c b/testsuites/psxtests/psx10/init.c
index 0c679a2441..6b2c9fa343 100644
--- a/testsuites/psxtests/psx10/init.c
+++ b/testsuites/psxtests/psx10/init.c
@@ -23,7 +23,8 @@ void *POSIX_Init(
pthread_t thread_id;
pthread_condattr_t attr;
int pshared;
- pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+ pthread_cond_t cond;
+ struct timespec timeout;
puts( "\n\n*** POSIX TEST 10 ***" );
@@ -89,17 +90,21 @@ void *POSIX_Init(
status = pthread_cond_destroy( &cond );
assert( !status );
+/* initiailize the attribute for the rest of the test */
+
puts( "Init: pthread_cond_init - attr" );
status = pthread_cond_init( &Cond1_id, &attr );
assert( !status );
- /* create a thread */
+/* signal task1 with a condition variable */
empty_line();
status = pthread_create( &Task_id, NULL, Task_1, NULL );
assert( !status );
+/* switch to task1 to allow it to wait for a condition variable */
+
puts( "Init: sleep to switch to Task_1" );
sleep( 1 );
@@ -112,16 +117,36 @@ void *POSIX_Init(
status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status );
+/* switch to task1 and task2 to allow them to wait for broadcast signal */
+
puts( "Init: sleep - switch to Task_1 and Task_2" );
sleep( 1 );
+/* broadcast a condition variable to task1 and task2 */
+
puts( "Init: pthread_cond_broadcast" );
status = pthread_cond_broadcast( &Cond1_id );
assert( !status );
puts( "Init: sleep - switch to Task_1" );
- sleep( 1 );
+ sleep( 0 );
+
+/* timedwait case - timeout */
+
+ status = pthread_mutex_lock( &Mutex_id );
+ assert( !status );
+
+/* set timeout to 3 seconds */
+
+ timeout.tv_sec = 3;
+
+ puts( "Init: pthread_cond_timedwait for 3 seconds" );
+ status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
+ if ( status != ETIMEDOUT )
+ printf( "status = %d\n", status );
+ assert( status == ETIMEDOUT );
+ puts( "Init: timedout on pthread_cond_timedwait release mutex" );
/* exit this thread */
puts( "*** END OF POSIX TEST 5 ***" );