Changeset 4b623d65 in rtems


Ignore:
Timestamp:
May 24, 2016, 5:40:18 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
b1860df5
Parents:
7088340
git-author:
Sebastian Huber <sebastian.huber@…> (05/24/16 05:40:18)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/24/16 13:37:10)
Message:

score: Fix blocking _CORE_message_queue_Submit()

Close #2718.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/mqueuesendsupp.c

    r7088340 r4b623d65  
    106106  );
    107107
    108   /*
    109    *  If we had to block, then this is where the task returns
    110    *  after it wakes up.  The returned status is correct for
    111    *  non-blocking operations but if we blocked, then we need
    112    *  to look at the status in our TCB.
    113    */
    114 
    115   if ( msg_status == CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT ) {
    116     msg_status = executing->Wait.return_code;
    117   }
    118 
    119108  if ( msg_status != CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL ) {
    120109    rtems_set_errno_and_return_minus_one(
  • cpukit/posix/src/mqueuetranslatereturncode.c

    r7088340 r4b623d65  
    4747  EAGAIN,                /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT */
    4848  EBADF,                 /* CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED */
    49   ETIMEDOUT,             /* CORE_MESSAGE_QUEUE_STATUS_TIMEOUT */
    50   ENOSYS                 /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT */
     49  ETIMEDOUT              /* CORE_MESSAGE_QUEUE_STATUS_TIMEOUT */
    5150};
    5251
  • cpukit/score/include/rtems/score/coremsgimpl.h

    r7088340 r4b623d65  
    9090   */
    9191  CORE_MESSAGE_QUEUE_STATUS_TIMEOUT,
    92   /** This value indicates that a blocking receive was unsuccessful. */
    93   CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT
    9492}   CORE_message_queue_Status;
    9593
     
    9997 *  This is the last status value.
    10098 */
    101 #define CORE_MESSAGE_QUEUE_STATUS_LAST CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT
     99#define CORE_MESSAGE_QUEUE_STATUS_LAST CORE_MESSAGE_QUEUE_STATUS_TIMEOUT
    102100
    103101/**
  • cpukit/score/src/coremsgsubmit.c

    r7088340 r4b623d65  
    134134     *  would be to use this variable prior to here.
    135135     */
     136    executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    136137    executing->Wait.return_argument_second.immutable_object = buffer;
    137138    executing->Wait.option = (uint32_t) size;
     
    147148      lock_context
    148149    );
    149     return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT;
     150    return executing->Wait.return_code;
    150151  #endif
    151152}
  • testsuites/psxtests/psxmsgq01/init.c

    r7088340 r4b623d65  
    12601260}
    12611261
     1262static void *receive_maxmsg_plus_one( void *arg )
     1263{
     1264  mqd_t                 mq;
     1265  const Test_Message_t *m;
     1266  int                   i;
     1267
     1268  mq = Test_q[ BLOCKING ].mq;
     1269  m = &Predefined_Msgs[ 0 ];
     1270
     1271  for ( i = 0; i < MAXMSG + 1; ++i ) {
     1272    Test_Message_t a;
     1273    unsigned       prio;
     1274    ssize_t        n;
     1275
     1276    n = mq_receive( mq, &a.msg[0], sizeof(a.msg), &prio);
     1277    rtems_test_assert( n == m->size );
     1278    rtems_test_assert( prio == m->priority );
     1279    rtems_test_assert( memcmp( &a.msg[0], &m->msg[0], (size_t) n ) == 0 );
     1280  }
     1281
     1282  return arg;
     1283}
     1284
     1285static void verify_blocking_mq_timedsend( void )
     1286{
     1287  mqd_t                 mq;
     1288  const Test_Message_t *m;
     1289  int                   status;
     1290  struct timespec       timeout;
     1291  pthread_t             thread;
     1292  void                 *exit_value;
     1293  rtems_status_code     sc;
     1294
     1295  Start_Test( "verify_blocking_mq_timedsend"  );
     1296
     1297  mq = Test_q[ BLOCKING ].mq;
     1298  m = &Predefined_Msgs[ 0 ];
     1299
     1300  /*
     1301   * Create and suspend the receive thread early so that we don't overwrite the
     1302   * ETIMEDOUT in executing->Wait.return_code.  This verifies the succesful
     1303   * mq_timedreceive() later.
     1304   */
     1305
     1306  status = pthread_create( &thread, NULL, receive_maxmsg_plus_one, &thread );
     1307  fatal_posix_service_status( status, 0, "pthread_create" );
     1308
     1309  sc = rtems_task_suspend( thread );
     1310  fatal_directive_status( sc, RTEMS_SUCCESSFUL, "rtems_task_suspend" );
     1311
     1312  do {
     1313    status = clock_gettime( CLOCK_REALTIME, &timeout );
     1314    fatal_posix_service_status( status, 0, "clock_gettime" );
     1315    ++timeout.tv_sec;
     1316
     1317    status = mq_timedsend( mq, m->msg, m->size , m->priority, &timeout );
     1318  } while ( status == 0 );
     1319
     1320  fatal_posix_service_status_errno( status, ETIMEDOUT, "mq_timedsend");
     1321
     1322  sc = rtems_task_resume( thread );
     1323  fatal_directive_status( sc, RTEMS_SUCCESSFUL, "rtems_task_restart" );
     1324
     1325  status = clock_gettime( CLOCK_REALTIME, &timeout );
     1326  fatal_posix_service_status( status, 0, "clock_gettime" );
     1327  ++timeout.tv_sec;
     1328
     1329  status = mq_timedsend( mq, m->msg, m->size , m->priority, &timeout );
     1330  fatal_posix_service_status( status, 0, "mq_timedsend" );
     1331
     1332  exit_value = NULL;
     1333  status = pthread_join( thread, &exit_value );
     1334  fatal_posix_service_status( status, 0, "pthread_join" );
     1335  rtems_test_assert( exit_value == &thread );
     1336}
     1337
    12621338void *POSIX_Init(
    12631339  void *argument
     
    12681344  validate_mq_open_error_codes( );
    12691345  open_test_queues();
     1346  verify_blocking_mq_timedsend();
    12701347  validate_mq_unlink_error_codes();
    12711348  validate_mq_close_error_codes();
  • testsuites/psxtests/psxmsgq01/psxmsgq01.scn

    r7088340 r4b623d65  
    1010Init: mq_close and mq_unlink (mq3...mqn) - SUCCESSFUL
    1111Init: Open Test Queues
     12_______________verify_blocking_mq_timedsend
    1213_______________mq_unlink errors
    1314Init: mq_unlink - mq_unlink with too long of a name (ENAMETOOLONG)
Note: See TracChangeset for help on using the changeset viewer.