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 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031
0032 #include <fcntl.h>
0033 #include <timesys.h>
0034 #include <rtems/btimer.h>
0035 #include <tmacros.h>
0036 #include "test_support.h"
0037 #include <sched.h>
0038 #include <pthread.h>
0039 #include <mqueue.h>
0040 #include <signal.h>
0041
0042 const char rtems_test_name[] = "PSXTMMQRCVBLOCK 02";
0043
0044
0045 void *POSIX_Init(void *argument);
0046 void *Middle(void *argument);
0047 void *Low(void *argument);
0048
0049 #define MQ_MAXMSG 1
0050 #define MQ_MSGSIZE sizeof(int)
0051
0052 static mqd_t queue;
0053 int message[MQ_MAXMSG];
0054 const char *q_name;
0055 unsigned int priority;
0056 struct timespec timeout;
0057
0058 void *POSIX_Init(
0059 void *argument
0060 )
0061 {
0062 int i;
0063 int status;
0064 int oflag = O_CREAT |O_RDWR;
0065 pthread_t threadId;
0066 struct mq_attr attr;
0067
0068 priority = 0;
0069 timeout.tv_sec = 0;
0070 timeout.tv_nsec = 0;
0071 attr.mq_maxmsg = MQ_MAXMSG;
0072 attr.mq_msgsize = MQ_MSGSIZE;
0073
0074 TEST_BEGIN();
0075
0076 for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
0077 status = pthread_create( &threadId, NULL, Middle, NULL );
0078 rtems_test_assert( !status );
0079 }
0080
0081 status = pthread_create( &threadId, NULL, Low, NULL );
0082 rtems_test_assert( !status );
0083
0084 queue = mq_open( "queue", oflag, 0x777, &attr );
0085
0086
0087 sched_yield();
0088
0089
0090 benchmark_timer_initialize();
0091 status = mq_timedreceive(
0092 queue, (char *)message, MQ_MSGSIZE, &priority, &timeout);
0093 return NULL;
0094 }
0095
0096 void *Middle(
0097 void *argument
0098 )
0099 {
0100 sched_yield();
0101
0102
0103
0104 (void) mq_timedreceive(
0105 queue, (char *)message, MQ_MSGSIZE, &priority, &timeout);
0106
0107 return NULL;
0108 }
0109
0110 void *Low(
0111 void *argument
0112 )
0113 {
0114 benchmark_timer_t end_time;
0115
0116 sched_yield();
0117
0118 end_time = benchmark_timer_read();
0119
0120 put_time(
0121 "mq_timedreceive: not available: block",
0122 end_time,
0123 OPERATION_COUNT,
0124 0,
0125 0
0126 );
0127
0128 TEST_END();
0129
0130 rtems_test_exit( 0 );
0131 return NULL;
0132 }
0133
0134
0135
0136 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
0137 #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
0138
0139 #define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
0140 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
0141
0142 #define CONFIGURE_INIT
0143
0144 #include <rtems/confdefs.h>
0145