mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-25 05:47:12 +00:00
2008-12-14 Joel Sherrill <joel.sherrill@oarcorp.com>
* psx05/init.c, psx07/init.c, psx09/init.c, psx11/init.c, psx12/init.c: Run all tests successfully with maxixum number of priorities as 16 instead of 256. This was done by temporarily modifying the score priority.h maximum. This allowed testing of all API code to ensure that it worked properly with a reduced number of priorities. Most modifications were to switch from hard-coded maximum to using the API provided methods to determine maximum number of priority levels.
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
2008-12-14 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* psx05/init.c, psx07/init.c, psx09/init.c, psx11/init.c, psx12/init.c:
|
||||
Run all tests successfully with maxixum number of priorities as 16
|
||||
instead of 256. This was done by temporarily modifying the score
|
||||
priority.h maximum. This allowed testing of all API code to ensure
|
||||
that it worked properly with a reduced number of priorities. Most
|
||||
modifications were to switch from hard-coded maximum to using the API
|
||||
provided methods to determine maximum number of priority levels.
|
||||
|
||||
2008-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* psxtimer01/psxtimer.c, psxtimer02/psxtimer.c: Obtain TOD with
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define CONFIGURE_INIT
|
||||
#include "system.h"
|
||||
#include <errno.h>
|
||||
#include <rtems/posix/priority.h>
|
||||
|
||||
#define MUTEX_BAD_ID 0xfffffffe
|
||||
|
||||
@@ -107,6 +108,7 @@ void *POSIX_Init(
|
||||
int protocol;
|
||||
int ceiling;
|
||||
int old_ceiling;
|
||||
int priority;
|
||||
|
||||
assert( MUTEX_BAD_ID != PTHREAD_MUTEX_INITIALIZER );
|
||||
Mutex_bad_id = MUTEX_BAD_ID;
|
||||
@@ -277,7 +279,10 @@ void *POSIX_Init(
|
||||
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
|
||||
assert( !status );
|
||||
|
||||
status = pthread_mutexattr_setprioceiling( &attr, 128 );
|
||||
status = pthread_mutexattr_setprioceiling(
|
||||
&attr,
|
||||
(sched_get_priority_max(SCHED_FIFO) / 2) + 1
|
||||
);
|
||||
assert( !status );
|
||||
|
||||
status = pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
|
||||
@@ -463,7 +468,7 @@ void *POSIX_Init(
|
||||
|
||||
/* set priority of Task2 to highest priority */
|
||||
|
||||
param.sched_priority = 254;
|
||||
param.sched_priority = sched_get_priority_max();
|
||||
|
||||
puts( "Init: pthread_setschedparam - Setting Task2 priority to highest" );
|
||||
status = pthread_setschedparam( Task2_id, SCHED_FIFO, ¶m );
|
||||
@@ -531,8 +536,11 @@ void *POSIX_Init(
|
||||
|
||||
/* normal cases of set priority ceiling */
|
||||
|
||||
puts( "Init: pthread_mutex_setprioceiling - new ceiling = 200" );
|
||||
status = pthread_mutex_setprioceiling( &Mutex2_id, 200, &old_ceiling );
|
||||
priority = sched_get_priority_max( SCHED_FIFO );
|
||||
priority = (priority == 254) ? 200 : 13;
|
||||
|
||||
printf( "Init: pthread_mutex_setprioceiling - new ceiling = %d", priority );
|
||||
status = pthread_mutex_setprioceiling( &Mutex2_id, priority, &old_ceiling );
|
||||
assert( !status );
|
||||
printf(
|
||||
"Init: pthread_mutex_setprioceiling - old ceiling = %d\n",old_ceiling
|
||||
@@ -561,7 +569,7 @@ void *POSIX_Init(
|
||||
|
||||
/* set priority of Task3 to highest priority */
|
||||
|
||||
param.sched_priority = 199;
|
||||
param.sched_priority = --priority;
|
||||
|
||||
status = pthread_setschedparam( Task3_id, SCHED_FIFO, ¶m );
|
||||
assert( !status );
|
||||
@@ -585,7 +593,7 @@ void *POSIX_Init(
|
||||
|
||||
/* set priority of Init to highest priority */
|
||||
|
||||
param.sched_priority = 254;
|
||||
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||
|
||||
status = pthread_setschedparam( Init_id, SCHED_FIFO, ¶m );
|
||||
assert( !status );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -499,7 +499,7 @@ void *POSIX_Init(
|
||||
status = pthread_setschedparam( pthread_self(), SCHED_OTHER, NULL );
|
||||
fatal_directive_check_status_only( status, EINVAL, "invalid priority" );
|
||||
|
||||
schedparam.sched_priority = 128;
|
||||
schedparam.sched_priority = sched_get_priority_max(SCHED_OTHER);
|
||||
|
||||
puts( "Init: pthread_setschedparam - EINVAL (invalid policy)" );
|
||||
status = pthread_setschedparam( pthread_self(), -1, &schedparam );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -13,6 +13,10 @@
|
||||
#include "system.h"
|
||||
#include <errno.h>
|
||||
|
||||
int HIGH_PRIORITY;
|
||||
int MEDIUM_PRIORITY;
|
||||
int LOW_PRIORITY;
|
||||
|
||||
void print_schedparam(
|
||||
char *prefix,
|
||||
struct sched_param *schedparam
|
||||
@@ -70,8 +74,8 @@ void *POSIX_Init(
|
||||
schedparam.ss_initial_budget.tv_sec = 0;
|
||||
schedparam.ss_initial_budget.tv_nsec = 250000000; /* 1/4 second */
|
||||
|
||||
schedparam.sched_priority = 200;
|
||||
schedparam.ss_low_priority = 100;
|
||||
schedparam.sched_priority = sched_get_priority_max(SCHED_SPORADIC);
|
||||
schedparam.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 );
|
||||
@@ -111,9 +115,9 @@ void *POSIX_Init(
|
||||
schedparam.ss_initial_budget.tv_sec = 0;
|
||||
schedparam.ss_initial_budget.tv_nsec = 250000000; /* 1/4 second */
|
||||
|
||||
#define HIGH_PRIORITY 150
|
||||
#define MEDIUM_PRIORITY 131
|
||||
#define LOW_PRIORITY 100
|
||||
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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -20,6 +20,10 @@ void *POSIX_Init(
|
||||
int status;
|
||||
struct sched_param param;
|
||||
pthread_attr_t attr;
|
||||
int priority_1;
|
||||
int priority_2;
|
||||
int priority_3;
|
||||
int priority_4;
|
||||
|
||||
puts( "\n\n*** POSIX TEST 11 ***" );
|
||||
|
||||
@@ -34,32 +38,47 @@ void *POSIX_Init(
|
||||
|
||||
/* exercise pthread_setschedparam */
|
||||
|
||||
param.sched_priority = 127;
|
||||
priority_1 = sched_get_priority_max( SCHED_FIFO ); /* was 127 */
|
||||
priority_2 = sched_get_priority_max( SCHED_FIFO ) - 2; /* was 125 */
|
||||
priority_3 = sched_get_priority_max( SCHED_FIFO ) - 6; /* was 121 */
|
||||
priority_4 = sched_get_priority_max( SCHED_FIFO ) - 7; /* was 120 */
|
||||
|
||||
puts( "Init: Setting scheduling parameters to FIFO with priority 127" );
|
||||
param.sched_priority = priority_1;
|
||||
|
||||
printf(
|
||||
"Init: Setting scheduling parameters to FIFO with priority %d\n",
|
||||
priority_1
|
||||
);
|
||||
status = pthread_setschedparam( Init_id, SCHED_FIFO, ¶m );
|
||||
assert( !status );
|
||||
|
||||
param.sched_priority = 125;
|
||||
param.sched_priority = priority_2;
|
||||
|
||||
puts( "Init: Setting scheduling parameters to RR with priority 125" );
|
||||
printf(
|
||||
"Init: Setting scheduling parameters to RR with priority %d\n",
|
||||
priority_2
|
||||
);
|
||||
status = pthread_setschedparam( Init_id, SCHED_RR, ¶m );
|
||||
assert( !status );
|
||||
|
||||
param.sched_priority = 121;
|
||||
param.sched_priority = priority_3;
|
||||
|
||||
puts( "Init: Setting scheduling parameters to OTHER with priority 121" );
|
||||
printf(
|
||||
"Init: Setting scheduling parameters to OTHER with priority %d\n",
|
||||
priority_3
|
||||
);
|
||||
status = pthread_setschedparam( Init_id, SCHED_OTHER, ¶m );
|
||||
assert( !status );
|
||||
|
||||
/* create a thread as SCHED_FIFO */
|
||||
|
||||
puts( "Init: create a thread of SCHED_FIFO with priority 120" );
|
||||
printf(
|
||||
"Init: create a thread of SCHED_FIFO with priority %d\n", priority_4 );
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
attr.schedpolicy = SCHED_FIFO;
|
||||
attr.schedparam.sched_priority = 120;
|
||||
attr.schedparam.sched_priority = priority_4;
|
||||
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( !status );
|
||||
@@ -70,12 +89,12 @@ void *POSIX_Init(
|
||||
|
||||
/* create a thread as SCHED_RR */
|
||||
|
||||
puts( "Init: create a thread of SCHED_RR with priority 120" );
|
||||
printf( "Init: create a thread of SCHED_RR with priority %d\n", priority_4 );
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
attr.schedpolicy = SCHED_RR;
|
||||
attr.schedparam.sched_priority = 120;
|
||||
attr.schedparam.sched_priority = priority_4;
|
||||
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( !status );
|
||||
@@ -86,12 +105,13 @@ void *POSIX_Init(
|
||||
|
||||
/* create a thread as SCHED_OTHER */
|
||||
|
||||
puts( "Init: create a thread of SCHED_OTHER with priority 120" );
|
||||
printf(
|
||||
"Init: create a thread of SCHED_OTHER with priority %d\n", priority_4 );
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
attr.schedpolicy = SCHED_OTHER;
|
||||
attr.schedparam.sched_priority = 120;
|
||||
attr.schedparam.sched_priority = priority_4;
|
||||
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( !status );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -117,8 +117,8 @@ void *POSIX_Init(
|
||||
schedparam.ss_initial_budget.tv_sec = 1;
|
||||
schedparam.ss_initial_budget.tv_nsec = 0;
|
||||
|
||||
schedparam.sched_priority = 200;
|
||||
schedparam.ss_low_priority = 100;
|
||||
schedparam.sched_priority = sched_get_priority_max( SCHED_FIFO );
|
||||
schedparam.ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
|
||||
|
||||
status = pthread_attr_setschedparam( &attr, &schedparam );
|
||||
assert( !status );
|
||||
|
||||
Reference in New Issue
Block a user