diff --git a/ChangeLog b/ChangeLog index 416f4787316..4280c0b611c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -161,6 +161,8 @@ * sched/usleep.c: Fixed nsec calculation * lib/lib_strcspn.c: Function incorrectly named strspn(). * examples/ostest/main.c: Errors in SDCC version of a memcpy() call - * examples/ostest/sighandl.c: Don't call fflush() if streams are disabled + * examples/ostest/sighand.c: Don't call fflush() if streams are disabled + * include/limits.h, include/time.h, sched/clock_internal.h: A support for + using selectable system timer frequency. * Started m68322 diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index c6800174287..6b5d03248cb 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@
Last Updated: May 26, 2007
+Last Updated: June 9, 2007
make.
number of memory regions that the memory manager must
handle and enables the API mm_addregion(start, end);
+ CONFIG_TICKS_PER_MSEC: The default system timer is 100Hz
+ or TICKS_PER_MSEC=10. This setting may be defined to inform NuttX
+ that the processor hardware is providing system timer interrupts at some interrupt
+ interval other than 10 msec.
+ CONFIG_RR_INTERVAL: The round robin timeslice will be set
this number of milliseconds; Round robin scheduling can
diff --git a/TODO b/TODO
index 0f16e150f03..3c5a1e83eca 100644
--- a/TODO
+++ b/TODO
@@ -7,10 +7,6 @@ o Task/Scheduler
- Implement sys/mman.h and functions
- Implement sys/wait.h and functions
- Implement priority inheritance
-- Make the system timer frequency configurable via defconfig. See:
- _POSIX_CLOCKRES_MIN in limits.h
- CLK_TCK in time.h
- MSEC_PER_TICK in sched/clock_internal.h
- Consider implementing wait, waitpid, waitid. At present, a parent has
no information about child tasks.
- Several APIs do not set errno. Need to review all APIs.
diff --git a/configs/README.txt b/configs/README.txt
index 77d41e13192..a123a1f0157 100644
--- a/configs/README.txt
+++ b/configs/README.txt
@@ -132,6 +132,11 @@ defconfig -- This is a configuration file similar to the Linux
regions of memory to allocate from, this specifies the
number of memory regions that the memory manager must
handle and enables the API mm_addregion(start, end);
+ CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+ or TICKS_PER_MSEC=10. This setting may be defined to
+ inform NuttX that the processor hardware is providing
+ system timer interrupts at some interrupt interval other
+ than 10 msec.
CONFIG_RR_INTERVAL - The round robin timeslice will be set
this number of milliseconds; Round robin scheduling can
be disabled by setting this value to zero.
diff --git a/configs/c5471evm/defconfig b/configs/c5471evm/defconfig
index a534ae283fc..e247d9e87ce 100644
--- a/configs/c5471evm/defconfig
+++ b/configs/c5471evm/defconfig
@@ -109,6 +109,11 @@ CONFIG_UART_MODEM_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/configs/m68332evb/defconfig b/configs/m68332evb/defconfig
index 2df6f2e516d..2185e760a24 100644
--- a/configs/m68332evb/defconfig
+++ b/configs/m68332evb/defconfig
@@ -98,6 +98,11 @@ CONFIG_UART1_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/configs/mcu123-lpc214x/defconfig b/configs/mcu123-lpc214x/defconfig
index e9e97326b25..ca0c9a15337 100644
--- a/configs/mcu123-lpc214x/defconfig
+++ b/configs/mcu123-lpc214x/defconfig
@@ -122,6 +122,11 @@ CONFIG_UART1_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/configs/ntosd-dm320/defconfig b/configs/ntosd-dm320/defconfig
index aa6270250f3..640783cf1df 100644
--- a/configs/ntosd-dm320/defconfig
+++ b/configs/ntosd-dm320/defconfig
@@ -107,6 +107,11 @@ CONFIG_UART1_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/configs/pjrc-8051/defconfig b/configs/pjrc-8051/defconfig
index bc6084f0bfa..c9b8a481a33 100644
--- a/configs/pjrc-8051/defconfig
+++ b/configs/pjrc-8051/defconfig
@@ -95,6 +95,11 @@ CONFIG_LED_DEBUG=n
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/configs/sim/defconfig b/configs/sim/defconfig
index 59f05d4ac1d..e5940848ea2 100644
--- a/configs/sim/defconfig
+++ b/configs/sim/defconfig
@@ -63,6 +63,11 @@ CONFIG_ARCH_BOARD_SIM=y
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/include/limits.h b/include/limits.h
index 285eea684fb..d32c7177a74 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -114,11 +114,27 @@
#define _POSIX_RTSIG_MAX 31
#define _POSIX_SIGQUEUE_MAX 32
-/* Required for POSIX timers */
+/* Required for POSIX timers.
+ *
+ * _POSIX_DELAYTIMER_MAX is the number of timer expiration overruns.
+ *
+ * _POSIX_TIMER_MAX is the per-process number of timers.
+ *
+ * _POSIX_CLOCKRES_MIN is the resolution of the CLOCK_REALTIME clock in nanoseconds.
+ * CLOCK_REALTIME is controlled by the NuttX system time. The default value is the
+ * system timer which has a resolution of 10 milliseconds. This default setting can
+ * be overridden by defining the clock interval in milliseconds as CONFIG_MSEC_PER_TICK
+ * in the board configuration file.
+ */
#define _POSIX_DELAYTIMER_MAX 32
#define _POSIX_TIMER_MAX 32
-#define _POSIX_CLOCKRES_MIN 10000000
+
+#ifdef CONFIG_MSEC_PER_TICK
+# define _POSIX_CLOCKRES_MIN ((CONFIG_MSEC_PER_TICK)*1000000)
+#else
+# define _POSIX_CLOCKRES_MIN (10*1000000)
+#endif
/* Required for asynchronous I/O */
diff --git a/include/time.h b/include/time.h
index 7a973142336..92b849fbeb6 100644
--- a/include/time.h
+++ b/include/time.h
@@ -51,9 +51,16 @@
* Definitions
********************************************************************************/
-/* Clock tick of the system */
+/* Clock tick of the system (frequency Hz). The default value is 100Hz, but this
+ * default setting can be overridden by defining the clock interval in
+ * milliseconds as CONFIG_MSEC_PER_TICK in the board configuration file.
+ */
-#define CLK_TCK 100
+#ifdef CONFIG_MSEC_PER_TICK
+# define CLK_TCK (1000/CONFIG_MSEC_PER_TICK)
+#else
+# define CLK_TCK (100)
+#endif
/* This is the only clock_id supported by the "Clock and Timer
* Functions."
diff --git a/sched/clock_internal.h b/sched/clock_internal.h
index 85cb13f0652..2f7a9c783bf 100644
--- a/sched/clock_internal.h
+++ b/sched/clock_internal.h
@@ -40,6 +40,7 @@
* Included Files
********************************************************************************/
+#include