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