summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <clark.williams@gmail.com>2015-01-15 12:35:05 -0600
committerClark Williams <clark.williams@gmail.com>2015-01-15 16:30:59 -0600
commit53956b6712fef18a7141c2b24dcf8815b5e46e9d (patch)
treef418836ca05015fd21c01132a029875ffbc582e4
parentd1f037dc3c83c04c8b291868cf39e238745f19eb (diff)
downloadrt-tests-53956b6712fef18a7141c2b24dcf8815b5e46e9d.tar.gz
pip_stress: parameterize usleep value to work-around platform issues
ARM platforms have timing issues with pip_stress: Hello, pip_stress works out of the box on my x86 based laptop, but doesn't work on ARM devices, returned 'no inversion incurred'. Follow the comment to increase usleep value, 2500 worked for pandaboard and 3000 worked for Beaglebone Black board. I propose that increase the usleep value to 3500 from upstream, so that we can use pip_stress right out of the box. Rather than hardcode the usleep value used by pip_stress, I made the command line option --usleep which takes a microsecond value that defaults to 500us. Reported-by: Chase Qi <chase.qi@linaro.org> Signed-off-by: Clark Williams <clark.williams@gmail.com>
-rw-r--r--src/pi_tests/pip_stress.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
index 2b42b8f..66b3dc1 100644
--- a/src/pi_tests/pip_stress.c
+++ b/src/pi_tests/pip_stress.c
@@ -56,6 +56,12 @@
#include "pip_stress.h"
+#include <unistd.h>
+#include <getopt.h>
+
+/* default time for low priority thread usleep */
+useconds_t usleep_val = 500;
+
pthread_mutex_t *resource;
/* This records the state to determine whether a priority inversion occured */
@@ -73,6 +79,11 @@ struct State *statep;
const int policy = SCHED_FIFO;
const int prio_min; /* Initialized for the minimum priority of policy */
+struct option long_options[] = {
+ { "usleep", required_argument, 0, 0 },
+ { 0, 0, 0, 0 },
+};
+
int main(void)
{
void *mptr; /* memory pointer */
@@ -80,6 +91,7 @@ int main(void)
cpu_set_t set, *setp = &set;
int res;
int *minimum_priority = (int*)&prio_min;
+ int c;
*minimum_priority = sched_get_priority_min(policy);
@@ -162,7 +174,7 @@ void low(pid_t pid)
statep->inversion = 0;
}
Pthread_mutex_unlock(statep->mutex);
- usleep(500);
+ usleep(usleep_val);
Pthread_mutex_unlock(resource);
waitpid(pid, &status, 0);
}