mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 14:18:20 +00:00
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.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
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
|
||||
|
||||
@@ -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" );
|
||||
|
||||
@@ -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 ***
|
||||
|
||||
Reference in New Issue
Block a user