forked from Imagelibrary/rtems
Reflect POSIX changes to sched_param.
This commit is contained in:
@@ -41,13 +41,14 @@ void print_schedparam(
|
||||
{
|
||||
printf( "%ssched priority = %d\n", prefix, schedparam->sched_priority );
|
||||
#if defined(_POSIX_SPORADIC_SERVER)
|
||||
printf( "%sss_low_priority = %d\n", prefix, schedparam->ss_low_priority );
|
||||
printf( "%sss_replenish_period = (%ld, %ld)\n", prefix,
|
||||
schedparam->ss_replenish_period.tv_sec,
|
||||
schedparam->ss_replenish_period.tv_nsec );
|
||||
printf( "%sss_initial_budget = (%ld, %ld)\n", prefix,
|
||||
schedparam->ss_initial_budget.tv_sec,
|
||||
schedparam->ss_initial_budget.tv_nsec );
|
||||
printf( "%ssched_ss_low_priority = %d\n",
|
||||
prefix, schedparam->sched_ss_low_priority );
|
||||
printf( "%ssched_ss_replenish_period = (%ld, %ld)\n", prefix,
|
||||
schedparam->sched_ss_repl_period.tv_sec,
|
||||
schedparam->sched_ss_repl_period.tv_nsec );
|
||||
printf( "%ssched_sched_ss_initial_budget = (%ld, %ld)\n", prefix,
|
||||
schedparam->sched_ss_init_budget.tv_sec,
|
||||
schedparam->sched_ss_init_budget.tv_nsec );
|
||||
#else
|
||||
printf( "%s_POSIX_SPORADIC_SERVER is not defined\n" );
|
||||
#endif
|
||||
@@ -533,38 +534,38 @@ void *POSIX_Init(
|
||||
|
||||
/* now get sporadic server errors */
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 0;
|
||||
schedparam.ss_replenish_period.tv_nsec = 0;
|
||||
schedparam.ss_initial_budget.tv_sec = 1;
|
||||
schedparam.ss_initial_budget.tv_nsec = 1;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 0;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 1;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 1;
|
||||
|
||||
puts( "Init - pthread_setschedparam - EINVAL (replenish == 0)" );
|
||||
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
|
||||
fatal_directive_check_status_only( status, EINVAL, "replenish == 0" );
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 1;
|
||||
schedparam.ss_replenish_period.tv_nsec = 1;
|
||||
schedparam.ss_initial_budget.tv_sec = 0;
|
||||
schedparam.ss_initial_budget.tv_nsec = 0;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 1;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 1;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 0;
|
||||
|
||||
puts( "Init - pthread_setschedparam - EINVAL (budget == 0)" );
|
||||
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
|
||||
fatal_directive_check_status_only( status, EINVAL, "budget == 0" );
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 1;
|
||||
schedparam.ss_replenish_period.tv_nsec = 0;
|
||||
schedparam.ss_initial_budget.tv_sec = 1;
|
||||
schedparam.ss_initial_budget.tv_nsec = 1;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 1;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 1;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 1;
|
||||
|
||||
puts( "Init - pthread_setschedparam - EINVAL (replenish < budget)" );
|
||||
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
|
||||
fatal_directive_check_status_only( status, EINVAL, "replenish < budget" );
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 2;
|
||||
schedparam.ss_replenish_period.tv_nsec = 0;
|
||||
schedparam.ss_initial_budget.tv_sec = 1;
|
||||
schedparam.ss_initial_budget.tv_nsec = 0;
|
||||
schedparam.ss_low_priority = -1;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 2;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 1;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 0;
|
||||
schedparam.sched_ss_low_priority = -1;
|
||||
|
||||
puts( "Init - pthread_setschedparam - EINVAL (invalid priority)" );
|
||||
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
|
||||
@@ -584,12 +585,12 @@ void *POSIX_Init(
|
||||
status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 3;
|
||||
schedparam.ss_replenish_period.tv_nsec = 3;
|
||||
schedparam.ss_initial_budget.tv_sec = 1;
|
||||
schedparam.ss_initial_budget.tv_nsec = 1;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 3;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 3;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 1;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 1;
|
||||
schedparam.sched_priority = sched_get_priority_max( SCHED_FIFO );
|
||||
schedparam.ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
|
||||
schedparam.sched_ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
|
||||
|
||||
puts( "Init - pthread_attr_setschedpolicy - SUCCESSFUL" );
|
||||
status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC );
|
||||
|
||||
@@ -31,13 +31,14 @@ void print_schedparam(
|
||||
{
|
||||
printf( "%ssched priority = %d\n", prefix, schedparam->sched_priority );
|
||||
#if defined(_POSIX_SPORADIC_SERVER)
|
||||
printf( "%sss_low_priority = %d\n", prefix, schedparam->ss_low_priority );
|
||||
printf( "%sss_replenish_period = (%ld, %ld)\n", prefix,
|
||||
schedparam->ss_replenish_period.tv_sec,
|
||||
schedparam->ss_replenish_period.tv_nsec );
|
||||
printf( "%sss_initial_budget = (%ld, %ld)\n", prefix,
|
||||
schedparam->ss_initial_budget.tv_sec,
|
||||
schedparam->ss_initial_budget.tv_nsec );
|
||||
printf( "%ssched_ss_low_priority = %d\n",
|
||||
prefix, schedparam->sched_ss_low_priority );
|
||||
printf( "%ssched_ss_repl_period = (%ld, %ld)\n", prefix,
|
||||
schedparam->sched_ss_repl_period.tv_sec,
|
||||
schedparam->sched_ss_repl_period.tv_nsec );
|
||||
printf( "%ssched_ss_init_budget = (%ld, %ld)\n", prefix,
|
||||
schedparam->sched_ss_init_budget.tv_sec,
|
||||
schedparam->sched_ss_init_budget.tv_nsec );
|
||||
#else
|
||||
printf( "%s_POSIX_SPORADIC_SERVER is not defined\n" );
|
||||
#endif
|
||||
@@ -78,13 +79,13 @@ void *POSIX_Init(
|
||||
sprintf( buffer, " - current priority = %d", priority );
|
||||
print_current_time( "Init: ", buffer );
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 0;
|
||||
schedparam.ss_replenish_period.tv_nsec = 500000000; /* 1/2 second */
|
||||
schedparam.ss_initial_budget.tv_sec = 0;
|
||||
schedparam.ss_initial_budget.tv_nsec = 250000000; /* 1/4 second */
|
||||
schedparam.sched_ss_repl_period.tv_sec = 0;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 500000000; /* 1/2 second */
|
||||
schedparam.sched_ss_init_budget.tv_sec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 250000000; /* 1/4 second */
|
||||
|
||||
schedparam.sched_priority = sched_get_priority_max(SCHED_SPORADIC);
|
||||
schedparam.ss_low_priority = sched_get_priority_max(SCHED_SPORADIC) - 2;
|
||||
schedparam.sched_ss_low_priority = sched_get_priority_max(SCHED_SPORADIC) - 2;
|
||||
|
||||
puts( "Init: pthread_setschedparam - SUCCESSFUL (sporadic server)" );
|
||||
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
|
||||
@@ -118,17 +119,17 @@ void *POSIX_Init(
|
||||
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 0;
|
||||
schedparam.ss_replenish_period.tv_nsec = 500000000; /* 1/2 second */
|
||||
schedparam.ss_initial_budget.tv_sec = 0;
|
||||
schedparam.ss_initial_budget.tv_nsec = 250000000; /* 1/4 second */
|
||||
schedparam.sched_ss_repl_period.tv_sec = 0;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 500000000; /* 1/2 second */
|
||||
schedparam.sched_ss_init_budget.tv_sec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 250000000; /* 1/4 second */
|
||||
|
||||
HIGH_PRIORITY = sched_get_priority_max( SCHED_SPORADIC );
|
||||
MEDIUM_PRIORITY = sched_get_priority_max( SCHED_SPORADIC ) - 2;
|
||||
LOW_PRIORITY = sched_get_priority_max( SCHED_SPORADIC ) - 4;
|
||||
|
||||
schedparam.sched_priority = HIGH_PRIORITY;
|
||||
schedparam.ss_low_priority = LOW_PRIORITY;
|
||||
schedparam.sched_ss_low_priority = LOW_PRIORITY;
|
||||
|
||||
puts( "Init: pthread_setschedparam - SUCCESSFUL (sporadic server)" );
|
||||
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
|
||||
|
||||
@@ -27,13 +27,14 @@ void print_schedparam(
|
||||
{
|
||||
printf( "%ssched priority = %d\n", prefix, schedparam->sched_priority );
|
||||
#if defined(_POSIX_SPORADIC_SERVER)
|
||||
printf( "%sss_low_priority = %d\n", prefix, schedparam->ss_low_priority );
|
||||
printf( "%sss_replenish_period = (%ld, %ld)\n", prefix,
|
||||
schedparam->ss_replenish_period.tv_sec,
|
||||
schedparam->ss_replenish_period.tv_nsec );
|
||||
printf( "%sss_initial_budget = (%ld, %ld)\n", prefix,
|
||||
schedparam->ss_initial_budget.tv_sec,
|
||||
schedparam->ss_initial_budget.tv_nsec );
|
||||
printf( "%ssched_ss_low_priority = %d\n",
|
||||
prefix, schedparam->sched_ss_low_priority );
|
||||
printf( "%ssched_ss_repl_period = (%ld, %ld)\n", prefix,
|
||||
schedparam->sched_ss_repl_period.tv_sec,
|
||||
schedparam->sched_ss_repl_period.tv_nsec );
|
||||
printf( "%ssched_ss_init_budget = (%ld, %ld)\n", prefix,
|
||||
schedparam->sched_ss_init_budget.tv_sec,
|
||||
schedparam->sched_ss_init_budget.tv_nsec );
|
||||
#else
|
||||
printf( "%s_POSIX_SPORADIC_SERVER is not defined\n" );
|
||||
#endif
|
||||
@@ -82,13 +83,13 @@ void *POSIX_Init(
|
||||
status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 1;
|
||||
schedparam.ss_replenish_period.tv_nsec = 0;
|
||||
schedparam.ss_initial_budget.tv_sec = 2;
|
||||
schedparam.ss_initial_budget.tv_nsec = 0;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 1;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 2;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 0;
|
||||
|
||||
schedparam.sched_priority = 200;
|
||||
schedparam.ss_low_priority = 100;
|
||||
schedparam.sched_ss_low_priority = 100;
|
||||
|
||||
status = pthread_attr_setschedparam( &attr, &schedparam );
|
||||
rtems_test_assert( !status );
|
||||
@@ -100,32 +101,32 @@ void *POSIX_Init(
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* invalid ss_low_priority error */
|
||||
/* invalid sched_ss_low_priority error */
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 2;
|
||||
schedparam.ss_replenish_period.tv_nsec = 0;
|
||||
schedparam.ss_initial_budget.tv_sec = 1;
|
||||
schedparam.ss_initial_budget.tv_nsec = 0;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 2;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 1;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 0;
|
||||
|
||||
schedparam.sched_priority = 200;
|
||||
schedparam.ss_low_priority = -1;
|
||||
schedparam.sched_ss_low_priority = -1;
|
||||
|
||||
status = pthread_attr_setschedparam( &attr, &schedparam );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_create - EINVAL (invalid ss_low_priority)" );
|
||||
puts( "Init: pthread_create - EINVAL (invalid sched_ss_low_priority)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* create a thread as a sporadic server */
|
||||
|
||||
schedparam.ss_replenish_period.tv_sec = 2;
|
||||
schedparam.ss_replenish_period.tv_nsec = 0;
|
||||
schedparam.ss_initial_budget.tv_sec = 1;
|
||||
schedparam.ss_initial_budget.tv_nsec = 0;
|
||||
schedparam.sched_ss_repl_period.tv_sec = 2;
|
||||
schedparam.sched_ss_repl_period.tv_nsec = 0;
|
||||
schedparam.sched_ss_init_budget.tv_sec = 1;
|
||||
schedparam.sched_ss_init_budget.tv_nsec = 0;
|
||||
|
||||
schedparam.sched_priority = sched_get_priority_max( SCHED_FIFO );
|
||||
schedparam.ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
|
||||
schedparam.sched_ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
|
||||
|
||||
status = pthread_attr_setschedparam( &attr, &schedparam );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
@@ -42,11 +42,11 @@ void test( void )
|
||||
|
||||
param.sched_priority = 0;
|
||||
#ifdef _POSIX_SPORADIC_SERVER
|
||||
param.ss_low_priority = 0;
|
||||
param.ss_replenish_period.tv_sec = 0;
|
||||
param.ss_replenish_period.tv_nsec = 0;
|
||||
param.ss_initial_budget.tv_sec = 0;
|
||||
param.ss_initial_budget.tv_nsec = 0;
|
||||
param.sched_ss_low_priority = 0;
|
||||
param.sched_ss_repl_period.tv_sec = 0;
|
||||
param.sched_ss_repl_period.tv_nsec = 0;
|
||||
param.sched_ss_init_budget.tv_sec = 0;
|
||||
param.sched_ss_init_budget.tv_nsec = 0;
|
||||
#endif
|
||||
|
||||
result = pthread_setschedparam( thread, policy, ¶m );
|
||||
|
||||
@@ -40,11 +40,11 @@ void test( void )
|
||||
|
||||
param.sched_priority = 0;
|
||||
#ifdef _POSIX_SPORADIC_SERVER
|
||||
param.ss_low_priority = 0;
|
||||
param.ss_replenish_period.tv_sec = 0;
|
||||
param.ss_replenish_period.tv_nsec = 0;
|
||||
param.ss_initial_budget.tv_sec = 0;
|
||||
param.ss_initial_budget.tv_nsec = 0;
|
||||
param.sched_ss_low_priority = 0;
|
||||
param.sched_ss_repl_period.tv_sec = 0;
|
||||
param.sched_ss_repl_period.tv_nsec = 0;
|
||||
param.sched_ss_init_budget.tv_sec = 0;
|
||||
param.sched_ss_init_budget.tv_nsec = 0;
|
||||
#endif
|
||||
|
||||
result = pthread_setschedparam( thread, policy, ¶m );
|
||||
|
||||
@@ -34,11 +34,11 @@ void test( void )
|
||||
|
||||
param.sched_priority = 0;
|
||||
#ifdef _POSIX_SPORADIC_SERVER
|
||||
param.ss_low_priority = 0;
|
||||
param.ss_replenish_period.tv_sec = 0;
|
||||
param.ss_replenish_period.tv_nsec = 0;
|
||||
param.ss_initial_budget.tv_sec = 0;
|
||||
param.ss_initial_budget.tv_nsec = 0;
|
||||
param.sched_ss_low_priority = 0;
|
||||
param.sched_ss_repl_period.tv_sec = 0;
|
||||
param.sched_ss_repl_period.tv_nsec = 0;
|
||||
param.sched_ss_init_budget.tv_sec = 0;
|
||||
param.sched_ss_init_budget.tv_nsec = 0;
|
||||
#endif
|
||||
|
||||
result = sched_setparam( pid, ¶m );
|
||||
|
||||
@@ -42,11 +42,11 @@ void test( void )
|
||||
|
||||
param.sched_priority = 0;
|
||||
#ifdef _POSIX_SPORADIC_SERVER
|
||||
param.ss_low_priority = 0;
|
||||
param.ss_replenish_period.tv_sec = 0;
|
||||
param.ss_replenish_period.tv_nsec = 0;
|
||||
param.ss_initial_budget.tv_sec = 0;
|
||||
param.ss_initial_budget.tv_nsec = 0;
|
||||
param.sched_ss_low_priority = 0;
|
||||
param.sched_ss_repl_period.tv_sec = 0;
|
||||
param.sched_ss_repl_period.tv_nsec = 0;
|
||||
param.sched_ss_init_budget.tv_sec = 0;
|
||||
param.sched_ss_init_budget.tv_nsec = 0;
|
||||
#endif
|
||||
|
||||
result = sched_setscheduler( pid, policy, ¶m );
|
||||
|
||||
Reference in New Issue
Block a user