summaryrefslogtreecommitdiff
path: root/nuttx/include/nuttx/clock.h
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-02-23 10:55:01 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-02-23 10:55:01 -0600
commit7c745cd460ea7361719b9fd18a35491beed92623 (patch)
treeb35642399f2cbe11bbe6c9a57f6cf2d90fea3ffb /nuttx/include/nuttx/clock.h
parent875b32e8389ac6e06bfb328e992c1865445d96c1 (diff)
downloadnuttx-7c745cd460ea7361719b9fd18a35491beed92623.tar.gz
nuttx-7c745cd460ea7361719b9fd18a35491beed92623.tar.bz2
nuttx-7c745cd460ea7361719b9fd18a35491beed92623.zip
CPU load calculations now available for all threads. Available in /proc/pid/loadavg
Diffstat (limited to 'nuttx/include/nuttx/clock.h')
-rw-r--r--nuttx/include/nuttx/clock.h45
1 files changed, 31 insertions, 14 deletions
diff --git a/nuttx/include/nuttx/clock.h b/nuttx/include/nuttx/clock.h
index d0fd9220f..d1315fbba 100644
--- a/nuttx/include/nuttx/clock.h
+++ b/nuttx/include/nuttx/clock.h
@@ -124,13 +124,13 @@
/****************************************************************************
* Public Types
****************************************************************************/
-/* This structure is used when CONFIG_SCHED_CPULOAD to sample CPU usage */
+/* This structure is used to report CPU usage for a particular thread */
#ifdef CONFIG_SCHED_CPULOAD
struct cpuload_s
{
- volatile uint32_t cnt; /* Total number of clock ticks */
- volatile uint32_t idle; /* Total number of clocks ticks with CPU IDLE */
+ volatile uint32_t total; /* Total number of clock ticks */
+ volatile uint32_t active; /* Number of ticks while this thread was active */
};
#endif
@@ -162,20 +162,14 @@ extern volatile uint32_t g_system_timer;
# endif
#endif
-/* CPU Load Measurements ***************************************************/
-/* This structure is used when CONFIG_SCHED_CPULOAD to sample CPU usage */
-
-#ifdef CONFIG_SCHED_CPULOAD
-extern volatile struct cpuload_s g_cpuload;
-#endif
-
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
-extern "C" {
+extern "C"
+{
#else
#define EXTERN extern
#endif
@@ -209,7 +203,7 @@ extern "C" {
****************************************************************************/
#ifdef CONFIG_RTC
-EXTERN void clock_synchronize(void);
+void clock_synchronize(void);
#endif
/****************************************************************************
@@ -235,7 +229,7 @@ EXTERN void clock_synchronize(void);
# ifdef CONFIG_SYSTEM_TIME64
# define clock_systimer() (uint32_t)(clock_systimer64() & 0x00000000ffffffff)
# else
-EXTERN uint32_t clock_systimer(void);
+uint32_t clock_systimer(void);
# endif
#endif
@@ -259,7 +253,30 @@ EXTERN uint32_t clock_systimer(void);
****************************************************************************/
#if !__HAVE_KERNEL_GLOBALS && defined(CONFIG_SYSTEM_TIME64)
-EXTERN uint64_t clock_systimer64(void);
+uint64_t clock_systimer64(void);
+#endif
+
+/****************************************************************************
+ * Function: clock_cpuload
+ *
+ * Description:
+ * Return load measurement data for the select PID.
+ *
+ * Parameters:
+ * pid - The task ID of the thread of interest. pid == 0 is the IDLE thread.
+ * cpuload - The location to return the CPU load
+ *
+ * Return Value:
+ * OK (0) on success; a negated errno value on failure. The only reason
+ * that this function can fail is if 'pid' no longer refers to a valid
+ * thread.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_CPULOAD
+int clock_cpuload(int pid, FAR struct cpuload_s *cpuload);
#endif
#undef EXTERN