Changeset c59479f in rtems for testsuites/support


Ignore:
Timestamp:
Nov 22, 2017, 8:26:02 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
83ad1c5
Parents:
f64f7a2f
git-author:
Sebastian Huber <sebastian.huber@…> (11/22/17 08:26:02)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/22/17 08:40:24)
Message:

tests: Use exponential backoff in locked_vprintf()

Without the exponential backoff a livelock was observed on a QorIQ P2020
with test SMP 5.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/support/src/locked_print.c

    rf64f7a2f rc59479f  
    1515#include "tmacros.h"
    1616
     17#include <unistd.h>
    1718#include <rtems/bspIo.h>
     19#include <rtems/counter.h>
    1820
    1921static rtems_id locked_print_semaphore;      /* synchronisation semaphore */
     
    6365
    6466  /* Lock semaphore without releasing the cpu */
    65   do {
    66     sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
    67   } while (sc != RTEMS_SUCCESSFUL );
     67  sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
     68
     69  if ( sc != RTEMS_SUCCESSFUL ) {
     70    uint8_t e;
     71    rtems_counter_ticks w;
     72
     73    /* Use exponential backoff to avoid a livelock */
     74
     75    getentropy( &e, sizeof( e ) );
     76    w = e + 1;
     77
     78    do {
     79      rtems_counter_delay_ticks( w );
     80      w *= 2;
     81      sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
     82    } while (sc != RTEMS_SUCCESSFUL );
     83  }
    6884
    6985  rv = vprintf(fmt, ap);
Note: See TracChangeset for help on using the changeset viewer.