summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-11-05 20:02:56 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-11-05 20:02:56 +0000
commit457f849544b54a0ba4c773e082b37c34fa726268 (patch)
treebdd380d9b47ff56c649468de2983d0516739beed
parent45630c3d55a534689f83fd8871c06399934645e1 (diff)
downloadnuttx-457f849544b54a0ba4c773e082b37c34fa726268.tar.gz
nuttx-457f849544b54a0ba4c773e082b37c34fa726268.tar.bz2
nuttx-457f849544b54a0ba4c773e082b37c34fa726268.zip
Make ostest RR scheduler test use less memory from Freddie Chopin; Plus build fix from Darcy Gong
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5314 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--apps/ChangeLog.txt5
-rw-r--r--apps/examples/README.txt11
-rw-r--r--apps/examples/elf/tests/Makefile2
-rw-r--r--apps/examples/nxflat/tests/Makefile2
-rw-r--r--apps/examples/ostest/Kconfig29
-rw-r--r--apps/examples/ostest/roundrobin.c156
-rw-r--r--apps/examples/relays/Makefile12
-rw-r--r--nuttx/Documentation/NuttX.html2
8 files changed, 119 insertions, 100 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index 8a168588b..d755fcca0 100644
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -407,3 +407,8 @@
and hardware address (from Darcy Gong).
6.24 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
+
+ * apps/examples/ostest/roundrobin.c: Replace large tables with
+ algorithmic prime number generation. This allows the roundrobin
+ test to run on platforms with minimal SRAM (Freddie Chopin).
+
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index 3bc6e50b5..3ee1abcf6 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -1087,6 +1087,17 @@ examples/ostest
Specifies the number of threads to create in the barrier
test. The default is 8 but a smaller number may be needed on
systems without sufficient memory to start so many threads.
+ * CONFIG_EXAMPLES_OSTEST_RR_RANGE
+ During round-robin scheduling test two threads are created. Each of the threads
+ searches for prime numbers in the configurable range, doing that configurable
+ number of times.
+ This value specifies the end of search range and together with number of runs
+ allows to configure the length of this test - it should last at least a few
+ tens of seconds. Allowed values [1; 32767], default 10000
+ * CONFIG_EXAMPLES_OSTEST_RR_RUNS
+ During round-robin scheduling test two threads are created. Each of the threads
+ searches for prime numbers in the configurable range, doing that configurable
+ number of times.
examples/pashello
^^^^^^^^^^^^^^^^^
diff --git a/apps/examples/elf/tests/Makefile b/apps/examples/elf/tests/Makefile
index d2192cb1e..778dd6480 100644
--- a/apps/examples/elf/tests/Makefile
+++ b/apps/examples/elf/tests/Makefile
@@ -117,4 +117,4 @@ $(SYMTAB_SRC): build
clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean)
@rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB_SRC) varlist.tmp
- @rm -rf $(ROMFS_DIR)
+ @rm -rf $(ROMFS_DIR) $(DIRLIST_HDR)
diff --git a/apps/examples/nxflat/tests/Makefile b/apps/examples/nxflat/tests/Makefile
index 36bb0e88e..4979c7fd4 100644
--- a/apps/examples/nxflat/tests/Makefile
+++ b/apps/examples/nxflat/tests/Makefile
@@ -98,6 +98,6 @@ $(SYMTAB): build
clean: $(foreach DIR, $(SUBDIRS), $(DIR)_clean)
@rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB)
- @rm -rf $(ROMFS_DIR)
+ @rm -rf $(ROMFS_DIR) $(ROMFS_DIRLIST)
diff --git a/apps/examples/ostest/Kconfig b/apps/examples/ostest/Kconfig
index 0da7e4ce3..3c64dc0c6 100644
--- a/apps/examples/ostest/Kconfig
+++ b/apps/examples/ostest/Kconfig
@@ -39,4 +39,33 @@ config EXAMPLES_OSTEST_NBARRIER_THREADS
is 8 but a smaller number may be needed on systems without sufficient memory
to start so many threads.
+config EXAMPLES_OSTEST_RR_RANGE
+ int "Round-robin test - end of search range"
+ default 10000
+ range 1 32767
+ depends on RR_INTERVAL > 0
+ ---help---
+ During round-robin scheduling test two threads are created. Each of the threads
+ searches for prime numbers in the configurable range, doing that configurable
+ number of times.
+
+ This value specifies the end of search range and together with number of runs
+ allows to configure the length of this test - it should last at least a few
+ tens of seconds. Allowed values [1; 32767], default 10000
+
+config EXAMPLES_OSTEST_RR_RUNS
+ int "Round-robin test - number of runs"
+ default 10
+ range 1 32767
+ depends on RR_INTERVAL > 0
+ ---help---
+ During round-robin scheduling test two threads are created. Each of the threads
+ searches for prime numbers in the configurable range, doing that configurable
+ number of times.
+
+ This value specifies the number of times the thread searches the range for
+ prime numbers and together with end of search range allows to configure the
+ length of this test - it should last at least a few tens of seconds. Allowed
+ values [1; 32767], default 10
+
endif
diff --git a/apps/examples/ostest/roundrobin.c b/apps/examples/ostest/roundrobin.c
index 5167a857e..bfd344df3 100644
--- a/apps/examples/ostest/roundrobin.c
+++ b/apps/examples/ostest/roundrobin.c
@@ -1,7 +1,7 @@
/********************************************************************************
* examples/ostest/roundrobin.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -39,6 +39,7 @@
#include <nuttx/config.h>
#include <stdio.h>
+#include <stdbool.h>
#include "ostest.h"
#if CONFIG_RR_INTERVAL > 0
@@ -47,115 +48,87 @@
* Definitions
********************************************************************************/
-/* This number may need to be tuned for different processor speeds. Since these
- * arrays must be large to very correct SCHED_RR behavior, this test may require
- * too much memory on many targets.
- */
+/* This numbers should be tuned for different processor speeds via .config file.
+ * With default values the test takes about 30s on Cortex-M3 @ 24MHz. With 32767
+ * range and 10 runs it takes ~320s. */
-/* #define CONFIG_NINTEGERS 32768 Takes forever on 60Mhz ARM7 */
-
-#define CONFIG_NINTEGERS 2048
-
-/********************************************************************************
- * Private Data
- ********************************************************************************/
+#ifndef CONFIG_EXAMPLES_OSTEST_RR_RANGE
+# define CONFIG_EXAMPLES_OSTEST_RR_RANGE 10000
+# warning "CONFIG_EXAMPLES_OSTEST_RR_RANGE undefined, using default value = 10000"
+#elif (CONFIG_EXAMPLES_OSTEST_RR_RANGE < 1) || (CONFIG_EXAMPLES_OSTEST_RR_RANGE > 32767)
+# define CONFIG_EXAMPLES_OSTEST_RR_RANGE 10000
+# warning "Invalid value of CONFIG_EXAMPLES_OSTEST_RR_RANGE, using default value = 10000"
+#endif
-static int prime1[CONFIG_NINTEGERS];
-static int prime2[CONFIG_NINTEGERS];
+#ifndef CONFIG_EXAMPLES_OSTEST_RR_RUNS
+# define CONFIG_EXAMPLES_OSTEST_RR_RUNS 10
+# warning "CONFIG_EXAMPLES_OSTEST_RR_RUNS undefined, using default value = 10"
+#elif (CONFIG_EXAMPLES_OSTEST_RR_RUNS < 1) || (CONFIG_EXAMPLES_OSTEST_RR_RUNS > 32767)
+# define CONFIG_EXAMPLES_OSTEST_RR_RUNS 10
+# warning "Invalid value of CONFIG_EXAMPLES_OSTEST_RR_RUNS, using default value = 10"
+#endif
/********************************************************************************
* Private Functions
********************************************************************************/
/********************************************************************************
- * Name: dosieve
+ * Name: get_primes
*
* Description
- * This implements a "sieve of aristophanes" algorithm for finding prime number.
- * Credit for this belongs to someone, but I am not sure who anymore. Anyway,
- * the only purpose here is that we need some algorithm that takes a long period
- * of time to execute.
- *
+ * This function searches for prime numbers in the most primitive way possible.
********************************************************************************/
-static void dosieve(int *prime)
+static void get_primes(int *count, int *last)
{
- int a,d;
- int i;
- int j;
-
- a = 2;
- d = a;
-
- for (i = 0; i < CONFIG_NINTEGERS; i++)
- {
- prime[i] = i+2;
- }
-
- for (i = 1; i < 10; i++)
+ int number;
+ int local_count = 0;
+ *last = 0; // to make compiler happy
+
+ for (number = 1; number < CONFIG_EXAMPLES_OSTEST_RR_RANGE; number++)
+ {
+ int div;
+ bool is_prime = true;
+
+ for (div = 2; div <= number / 2; div++)
+ if (number % div == 0)
+ {
+ is_prime = false;
+ break;
+ }
+
+ if (is_prime)
{
- for (j = 0; j < CONFIG_NINTEGERS; j++)
- {
- d = a + d;
- if (d < CONFIG_NINTEGERS)
- {
- prime[d]=0;
- }
- }
- a++;
- d = a;
- i++;
- }
-
+ local_count++;
+ *last = number;
#if 0 /* We don't really care what the numbers are */
- for (i = 0, j= 0; i < CONFIG_NINTEGERS; i++)
- {
- if (prime[i] != 0)
- {
- printf(" Prime %d: %d\n", j, prime[i]);
- j++;
- }
- }
+ printf(" Prime %d: %d\n", local_count, number);
#endif
-}
-
-/********************************************************************************
- * Name: sieve1
- ********************************************************************************/
-
-static void *sieve1(void *parameter)
-{
- int i;
-
- printf("sieve1 started\n");
-
- for (i = 0; i < 1000; i++)
- {
- dosieve(prime1);
}
+ }
- printf("sieve1 finished\n");
-
- pthread_exit(NULL);
- return NULL; /* To keep some compilers happy */
+ *count = local_count;
}
/********************************************************************************
- * Name: sieve2
+ * Name: get_primes_thread
********************************************************************************/
-static void *sieve2(void *parameter)
+static void *get_primes_thread(void *parameter)
{
- int i;
+ int id = (int)parameter;
+ int i, count, last;
- printf("sieve2 started\n");
+ printf("get_primes_thread id=%d started, looking for primes < %d, doing %d run(s)\n",
+ id, CONFIG_EXAMPLES_OSTEST_RR_RANGE, CONFIG_EXAMPLES_OSTEST_RR_RUNS);
- for (i = 0; i < 1000; i++)
+ for (i = 0; i < CONFIG_EXAMPLES_OSTEST_RR_RUNS; i++)
{
- dosieve(prime2);
+ get_primes(&count, &last);
}
- printf("sieve2 finished\n");
+ printf("get_primes_thread id=%d finished, found %d primes, last one was %d\n",
+ id, count, last);
pthread_exit(NULL);
return NULL; /* To keep some compilers happy */
@@ -171,14 +144,13 @@ static void *sieve2(void *parameter)
void rr_test(void)
{
- pthread_t sieve1_thread;
- pthread_t sieve2_thread;
+ pthread_t get_primes1_thread;
+ pthread_t get_primes2_thread;
struct sched_param sparam;
pthread_attr_t attr;
pthread_addr_t result;
int status;
- printf("rr_test: Starting sieve1 thread \n");
status = pthread_attr_init(&attr);
if (status != OK)
{
@@ -203,29 +175,31 @@ void rr_test(void)
}
else
{
- printf("rr_test: Set thread policty to SCHED_RR\n");
+ printf("rr_test: Set thread policy to SCHED_RR\n");
}
- status = pthread_create(&sieve1_thread, &attr, sieve1, NULL);
+ printf("rr_test: Starting first get_primes_thread\n");
+
+ status = pthread_create(&get_primes1_thread, &attr, get_primes_thread, (void*)1);
if (status != 0)
{
printf("rr_test: Error in thread 1 creation, status=%d\n", status);
}
- printf("rr_test: Starting sieve1 thread \n");
+ printf("rr_test: Starting second get_primes_thread\n");
- status = pthread_create(&sieve2_thread, &attr, sieve2, NULL);
+ status = pthread_create(&get_primes2_thread, &attr, get_primes_thread, (void*)2);
if (status != 0)
{
printf("rr_test: Error in thread 2 creation, status=%d\n", status);
}
- printf("rr_test: Waiting for sieves to complete -- this should take awhile\n");
+ printf("rr_test: Waiting for threads to complete -- this should take awhile\n");
printf("rr_test: If RR scheduling is working, they should start and complete at\n");
printf("rr_test: about the same time\n");
- pthread_join(sieve2_thread, &result);
- pthread_join(sieve1_thread, &result);
+ pthread_join(get_primes2_thread, &result);
+ pthread_join(get_primes1_thread, &result);
printf("rr_test: Done\n");
}
diff --git a/apps/examples/relays/Makefile b/apps/examples/relays/Makefile
index 6641c94b4..4a6530693 100644
--- a/apps/examples/relays/Makefile
+++ b/apps/examples/relays/Makefile
@@ -39,14 +39,14 @@ include $(APPDIR)/Make.defs
# relays Example
-ASRC =
-CSRC = relays_main.c
+ASRCS =
+CSRCS = relays_main.c
-AOBJ = $(ASRCS:.S=$(OBJEXT))
-COBJ = $(CSRCS:.c=$(OBJEXT))
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
-SRC = $(ASRCS) $(CSRCS)
-OBJ = $(AOBJS) $(COBJS)
+SRCS = $(ASRCS) $(CSRCS)
+OBJS = $(AOBJS) $(COBJS)
ifeq ($(WINTOOL),y)
BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}"
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index af8133534..dd7b83cfc 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -560,7 +560,7 @@
<td><br></td>
<td>
<p>
- <li>Add-on <a href="http://cxx.uclibc.org/">uClibc++</a> module provides Standard C++ Library(LGPL).</li>
+ <li>Add-on <a href="http://cxx.uclibc.org/">uClibc++</a> module provides Standard C++ Library (LGPL).</li>
</p>
</td>
</tr>