File indexing completed on 2025-05-11 08:24:41
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 <timesys.h>
0034 #include <pthread.h>
0035 #include <sched.h>
0036 #include <rtems/btimer.h>
0037 #include "test_support.h"
0038
0039 const char rtems_test_name[] = "PSXTMTHREAD 02";
0040
0041
0042 void *POSIX_Init(void *argument);
0043 void benchmark_pthread_create(void);
0044 void *thread(void *argument);
0045
0046 void benchmark_pthread_create(void)
0047 {
0048 int status;
0049 pthread_t thread_ID;
0050 pthread_attr_t attr;
0051 struct sched_param param;
0052
0053 status = pthread_attr_init(&attr);
0054 rtems_test_assert( status == 0 );
0055
0056 status = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
0057 rtems_test_assert( status == 0 );
0058
0059 status = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
0060 rtems_test_assert( status == 0 );
0061
0062 param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
0063 status = pthread_attr_setschedparam(&attr, ¶m);
0064 rtems_test_assert( status == 0 );
0065
0066
0067 benchmark_timer_initialize();
0068 status = pthread_create(&thread_ID, &attr, thread, NULL);
0069 }
0070
0071 void *thread(
0072 void *argument
0073 )
0074 {
0075 uint32_t end_time;
0076
0077 end_time = benchmark_timer_read();
0078 put_time(
0079 "pthread_create: preempt",
0080 end_time,
0081 1,
0082 0,
0083 0
0084 );
0085 return NULL;
0086 }
0087
0088 void *POSIX_Init(
0089 void *argument
0090 )
0091 {
0092
0093 TEST_BEGIN();
0094
0095 benchmark_pthread_create();
0096
0097 TEST_END();
0098 rtems_test_exit(0);
0099 }
0100
0101
0102
0103 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0104 #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
0105
0106 #define CONFIGURE_MAXIMUM_POSIX_THREADS 2
0107 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
0108
0109 #define CONFIGURE_INIT
0110
0111 #include <rtems/confdefs.h>
0112