diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-08-19 17:28:19 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-08-19 17:28:19 +0000 |
commit | c45ca1037563711069d65a6e6705670ea2c51e71 (patch) | |
tree | 4f0370aa6a1eb8f0d3ce39a5904aa8f86fd2f303 /testsuites/psxtests | |
parent | Give credit to Santosh. (diff) | |
download | rtems-c45ca1037563711069d65a6e6705670ea2c51e71.tar.bz2 |
2009-08-19 Joel Sherrill <joel.sherrill@OARcorp.com>
* psx09/init.c, psx09/psx09.scn: Correct test following decision of
when not to change ssporadic scheduler so it does not touch a task's
priority when it is holding a mutex or its priority would be impacted
adversely.
Diffstat (limited to '')
-rw-r--r-- | testsuites/psxtests/ChangeLog | 7 | ||||
-rw-r--r-- | testsuites/psxtests/psx09/init.c | 48 | ||||
-rw-r--r-- | testsuites/psxtests/psx09/psx09.scn | 22 |
3 files changed, 38 insertions, 39 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 19a8443e1e..ae63798660 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,5 +1,12 @@ 2009-08-19 Joel Sherrill <joel.sherrill@OARcorp.com> + * psx09/init.c, psx09/psx09.scn: Correct test following decision of + when not to change ssporadic scheduler so it does not touch a task's + priority when it is holding a mutex or its priority would be impacted + adversely. + +2009-08-19 Joel Sherrill <joel.sherrill@OARcorp.com> + * psxtime/main.c, psxtime/psxtime.scn, psxtime/test.c: Add test case for adjusting time (adjtime()) where the time is adjusted by enough microseconds that it crosses a second boundary. diff --git a/testsuites/psxtests/psx09/init.c b/testsuites/psxtests/psx09/init.c index b840d4bf11..dc79dc637d 100644 --- a/testsuites/psxtests/psx09/init.c +++ b/testsuites/psxtests/psx09/init.c @@ -52,6 +52,8 @@ void *POSIX_Init( struct sched_param schedparam; char buffer[ 80 ]; pthread_mutexattr_t attr; + time_t start; + time_t now; puts( "\n\n*** POSIX TEST 9 ***" ); @@ -111,7 +113,6 @@ void *POSIX_Init( empty_line(); - status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); assert( !status ); @@ -135,10 +136,7 @@ void *POSIX_Init( status = pthread_mutexattr_init( &attr ); assert( !status ); - status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT ); - assert( !status ); - - status = pthread_mutexattr_setprioceiling( &attr, MEDIUM_PRIORITY ); + status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT ); assert( !status ); puts( "Init: Creating a mutex" ); @@ -154,25 +152,33 @@ void *POSIX_Init( sprintf( buffer, " - new priority = %d", priority ); print_current_time( "Init: ", buffer ); - /* go into a loop consuming CPU time to watch our priority lower */ + /* go into a loop consuming CPU time to watch our priority NOT lower */ + + start = time( &start ); + + puts( "Init: pthread_mutex_lock acquire the lock" ); + status = pthread_mutex_lock( &Mutex_id ); + if ( status ) + printf( "status = %d %s\n", status, strerror(status) ); + assert( !status ); for ( ; ; ) { status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); assert( !status ); - if ( schedparam.sched_priority != LOW_PRIORITY ) - continue; + if ( schedparam.sched_priority == LOW_PRIORITY ) { + puts( "ERROR - Init's priority lowered while holding mutex" ); + rtems_test_exit(0); + } + + now = time( &now ); + if ( now - start > 3 ) + break; priority = schedparam.sched_priority; sprintf( buffer, " - new priority = %d", priority ); print_current_time( "Init: ", buffer ); - puts( "Init: pthread_mutex_lock acquire the lock" ); - status = pthread_mutex_lock( &Mutex_id ); - if ( status ) - printf( "status = %d\n", status ); - assert( !status ); - status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); assert( !status ); @@ -183,20 +189,6 @@ void *POSIX_Init( break; } - /* now spin waiting for our budget to be replenished */ - - for ( ; ; ) { - status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); - assert( !status ); - - if ( schedparam.sched_priority == HIGH_PRIORITY ) - break; - } - - priority = schedparam.sched_priority; - sprintf( buffer, " - new priority = %d", priority ); - print_current_time( "Init: ", buffer ); - /* with this unlock we should be able to go to low priority */ puts( "Init: unlock mutex" ); diff --git a/testsuites/psxtests/psx09/psx09.scn b/testsuites/psxtests/psx09/psx09.scn index adf62c5ee3..c3e6dadc71 100644 --- a/testsuites/psxtests/psx09/psx09.scn +++ b/testsuites/psxtests/psx09/psx09.scn @@ -3,20 +3,20 @@ Init's ID is 0x0b010001 Init: pthread_getschedparam - SUCCESSFUL Init: Fri May 24 11:05:00 1996 - current priority = 2 Init: pthread_setschedparam - SUCCESSFUL (sporadic server) -Init: Fri May 24 11:05:00 1996 - new priority = 200 -Init: Fri May 24 11:05:00 1996 - new priority = 100 -Init: Fri May 24 11:05:00 1996 - new priority = 200 -Init: Fri May 24 11:05:00 1996 - new priority = 100 -Init: Fri May 24 11:05:01 1996 - new priority = 200 +Init: Fri May 24 11:05:00 1996 - new priority = 254 +Init: Fri May 24 11:05:00 1996 - new priority = 252 +Init: Fri May 24 11:05:00 1996 - new priority = 254 +Init: Fri May 24 11:05:00 1996 - new priority = 252 +Init: Fri May 24 11:05:01 1996 - new priority = 254 + Init: pthread_setschedparam - SUCCESSFUL (sporadic server) Init: Initializing mutex attributes for priority ceiling Init: Creating a mutex -Init: Fri May 24 11:05:01 1996 - new priority = 150 -Init: Fri May 24 11:05:01 1996 - new priority = 100 +Init: Fri May 24 11:05:01 1996 - new priority = 254 Init: pthread_mutex_lock acquire the lock -Init: Fri May 24 11:05:01 1996 - new priority = 131 -Init: Fri May 24 11:05:01 1996 - new priority = 150 +Init: Fri May 24 11:05:01 1996 - new priority = 254 +Init: Fri May 24 11:05:01 1996 - new priority = 254 Init: unlock mutex -Init: Fri May 24 11:05:01 1996 - new priority = 150 -Init: Fri May 24 11:05:01 1996 - new priority = 100 +Init: Fri May 24 11:05:01 1996 - new priority = 254 +Init: Fri May 24 11:05:01 1996 - new priority = 250 *** END OF POSIX TEST 9 *** |