From ae2e61c7648ab0164cc79ff02a77b5a25f02987c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 27 Jul 2015 15:52:27 -0600 Subject: [PATCH] OS test: improve the sporadic scheduler test by waiting for a bit in the 'nuisance' thread --- examples/ostest/sporadic.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/ostest/sporadic.c b/examples/ostest/sporadic.c index 5d4049543..48677afc9 100644 --- a/examples/ostest/sporadic.c +++ b/examples/ostest/sporadic.c @@ -73,13 +73,35 @@ static time_t g_start_time; * Private Functions ***********************************************************************/ +void my_mdelay(unsigned int milliseconds) +{ + volatile unsigned int i; + volatile unsigned int j; + + for (i = 0; i < milliseconds; i++) + { + for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++) + { + } + } +} static void *nuisance_func(void *parameter) { + /* Synchronized start */ + while (sem_wait(&g_sporadic_sem) < 0); + /* Sleep until we are cancelled */ + for (;;) { + /* Sleep gracefully for awhile */ + usleep(500*1000); + + /* Then hog some CPU time */ + + my_mdelay(100); } return NULL;