File indexing completed on 2025-05-11 08:24:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <sched.h>
0034
0035 #define CONFIGURE_INIT
0036 #include "system.h"
0037 #include <errno.h>
0038
0039 const char rtems_test_name[] = "PSX 11";
0040
0041 void *POSIX_Init(
0042 void *argument
0043 )
0044 {
0045 int status;
0046 struct sched_param param;
0047 pthread_attr_t attr;
0048 int priority_1;
0049 int priority_2;
0050 int priority_3;
0051 int priority_4;
0052
0053 TEST_BEGIN();
0054
0055
0056
0057 set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
0058
0059
0060
0061 Init_id = pthread_self();
0062 printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
0063
0064
0065
0066 priority_1 = sched_get_priority_max( SCHED_FIFO );
0067 priority_2 = sched_get_priority_max( SCHED_FIFO ) - 2;
0068 priority_3 = sched_get_priority_max( SCHED_FIFO ) - 6;
0069 priority_4 = sched_get_priority_max( SCHED_FIFO ) - 7;
0070
0071 param.sched_priority = priority_1;
0072
0073 printf(
0074 "Init: Setting scheduling parameters to FIFO with priority %d\n",
0075 priority_1
0076 );
0077 status = pthread_setschedparam( Init_id, SCHED_FIFO, ¶m );
0078 rtems_test_assert( !status );
0079
0080 param.sched_priority = priority_2;
0081
0082 printf(
0083 "Init: Setting scheduling parameters to RR with priority %d\n",
0084 priority_2
0085 );
0086 status = pthread_setschedparam( Init_id, SCHED_RR, ¶m );
0087 rtems_test_assert( !status );
0088
0089 param.sched_priority = priority_3;
0090
0091 printf(
0092 "Init: Setting scheduling parameters to OTHER with priority %d\n",
0093 priority_3
0094 );
0095 status = pthread_setschedparam( Init_id, SCHED_OTHER, ¶m );
0096 rtems_test_assert( !status );
0097
0098
0099
0100 printf(
0101 "Init: create a thread of SCHED_FIFO with priority %d\n", priority_4 );
0102 status = pthread_attr_init( &attr );
0103 rtems_test_assert( !status );
0104
0105 attr.schedpolicy = SCHED_FIFO;
0106 attr.schedparam.sched_priority = priority_4;
0107
0108 status = pthread_create( &Task_id, &attr, Task_1, NULL );
0109 rtems_test_assert( !status );
0110
0111 puts( "Init: join with the other thread" );
0112 status = pthread_join( Task_id, NULL );
0113 rtems_test_assert( !status );
0114
0115
0116
0117 printf( "Init: create a thread of SCHED_RR with priority %d\n", priority_4 );
0118 status = pthread_attr_init( &attr );
0119 rtems_test_assert( !status );
0120
0121 status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
0122 rtems_test_assert( !status );
0123 attr.schedpolicy = SCHED_RR;
0124 attr.schedparam.sched_priority = priority_4;
0125
0126 status = pthread_create( &Task_id, &attr, Task_1, NULL );
0127 rtems_test_assert( !status );
0128
0129 puts( "Init: join with the other thread" );
0130 status = pthread_join( Task_id, NULL );
0131 rtems_test_assert( !status );
0132
0133
0134
0135 printf(
0136 "Init: create a thread of SCHED_OTHER with priority %d\n", priority_4 );
0137 status = pthread_attr_init( &attr );
0138 rtems_test_assert( !status );
0139
0140 attr.schedpolicy = SCHED_OTHER;
0141 attr.schedparam.sched_priority = priority_4;
0142
0143 status = pthread_create( &Task_id, &attr, Task_1, NULL );
0144 rtems_test_assert( !status );
0145
0146 puts( "Init: join with the other thread" );
0147 status = pthread_join( Task_id, NULL );
0148 rtems_test_assert( !status );
0149
0150 TEST_END();
0151 rtems_test_exit( 0 );
0152
0153 return NULL;
0154 }