Revision e7c4f797
core/inc/aos_thread.h | ||
---|---|---|
125 | 125 |
#if ((AMIROOS_CFG_DBG == true) && (CH_DBG_FILL_THREADS == TRUE)) || defined(__DOXYGEN__) |
126 | 126 |
size_t aosThdGetStackPeakUtilization(thread_t* thread); |
127 | 127 |
#endif /* (AMIROOS_CFG_DBG == true) && (CH_DBG_FILL_THREADS == TRUE) */ |
128 |
#if ((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) || defined(__DOXYGEN__) |
|
129 |
thread_t* aosThreadGetFirst(void); |
|
130 |
thread_t* aosThreadGetNext(thread_t* thread); |
|
131 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE) */ |
|
128 | 132 |
#if defined(__cplusplus) |
129 | 133 |
} |
130 | 134 |
#endif /* defined(_cplusplus) */ |
core/src/aos_system.c | ||
---|---|---|
88 | 88 |
static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv[]); |
89 | 89 |
static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]); |
90 | 90 |
static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* argv[]); |
91 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
91 |
#if (((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
92 | 92 |
static int _shellcmd_cpuloadcb(BaseSequentialStream* stream, int argc, char* argv[]); |
93 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */
|
|
93 |
#endif /* ((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE) */
|
|
94 | 94 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
95 | 95 |
static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char* argv[]); |
96 | 96 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
... | ... | |
147 | 147 |
static AOS_SHELL_COMMAND(_shellcmd_shutdown, "module:shutdown", _shellcmd_shutdowncb); |
148 | 148 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
149 | 149 |
|
150 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
150 |
#if (((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
151 | 151 |
|
152 | 152 |
/** |
153 | 153 |
* @brief Shell command to read out CPU load. |
154 | 154 |
*/ |
155 | 155 |
static AOS_SHELL_COMMAND(_shellcmd_cpuload, "module:cpuload", _shellcmd_cpuloadcb); |
156 | 156 |
|
157 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */
|
|
157 |
#endif /* ((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE) */
|
|
158 | 158 |
|
159 | 159 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
160 | 160 |
|
... | ... | |
643 | 643 |
#endif /* (AMIROOS_CFG_BOOTLOADER == X) */ |
644 | 644 |
} |
645 | 645 |
|
646 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
646 |
#if (((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
647 | 647 |
|
648 | 648 |
/** |
649 | 649 |
* @brief Callback function for the module:cpuload shell command. |
... | ... | |
663 | 663 |
|
664 | 664 |
// local variables |
665 | 665 |
rttime_t sum = 0; |
666 |
thread_t* thd = chRegFirstThread();
|
|
666 |
thread_t* thd = aosThreadGetFirst();
|
|
667 | 667 |
|
668 | 668 |
// accumulate system load |
669 | 669 |
do { |
670 | 670 |
sum += thd->stats.cumulative; |
671 |
thd = chRegNextThread(thd);
|
|
671 |
thd = aosThreadGetNext(thd);
|
|
672 | 672 |
} while (thd); |
673 | 673 |
sum += ch.kernel_stats.m_crit_thd.cumulative; |
674 | 674 |
sum += ch.kernel_stats.m_crit_isr.cumulative; |
675 | 675 |
|
676 | 676 |
// retrieve, calculate and print performance measures |
677 | 677 |
chprintf(stream, "threads & critical zones:\n"); |
678 |
thd = chRegFirstThread();
|
|
678 |
thd = aosThreadGetFirst();
|
|
679 | 679 |
do { |
680 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
680 | 681 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
681 | 682 |
(thd->name != NULL) ? thd->name : "<unnamed thread>", |
682 | 683 |
(double)((float)thd->stats.cumulative / (float)sum * 100.f)); |
683 |
thd = chRegNextThread(thd); |
|
684 |
#else |
|
685 |
chprintf(stream, "\t thread 0x%08X: %6.2f%%\n", (unsigned int)thd, (double)((float)thd->stats.cumulative / (float)sum * 100.f)); |
|
686 |
#endif |
|
687 |
thd = aosThreadGetNext(thd); |
|
684 | 688 |
} while (thd); |
685 | 689 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
686 | 690 |
"thread critical zones", |
... | ... | |
701 | 705 |
return 0; |
702 | 706 |
} |
703 | 707 |
|
704 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */
|
|
708 |
#endif /* ((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE) */
|
|
705 | 709 |
|
706 | 710 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
707 | 711 |
|
... | ... | |
780 | 784 |
{ |
781 | 785 |
size_t threads = 0; |
782 | 786 |
|
783 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
784 |
thread_t* tp = chRegFirstThread(); |
|
787 |
thread_t* tp = aosThreadGetFirst(); |
|
785 | 788 |
while (tp) { |
786 | 789 |
threads += (tp->state != CH_STATE_FINAL) ? 1 : 0; |
787 |
tp = chRegNextThread(tp);
|
|
790 |
tp = aosThreadGetNext(tp);
|
|
788 | 791 |
} |
789 |
#elif (CH_CFG_USE_THREADHIERARCHY == TRUE) |
|
790 |
enum { |
|
791 |
TRAVERSE_DOWN, |
|
792 |
TRAVERSE_UP, |
|
793 |
} traverse = TRAVERSE_UP; |
|
794 |
thread_t* tp = chThdGetSelfX(); |
|
795 |
// traverse to root thread |
|
796 |
while (tp->parent) { |
|
797 |
tp = tp->parent; |
|
798 |
} |
|
799 |
// systematically count all threads |
|
800 |
traverse = TRAVERSE_DOWN; |
|
801 |
while (tp) { |
|
802 |
if (traverse == TRAVERSE_DOWN && tp->children) { |
|
803 |
tp = tp->children; |
|
804 |
} else { |
|
805 |
threads += (tp->state != CH_STATE_FINAL) ? 1 : 0; |
|
806 |
if (tp->sibling) { |
|
807 |
tp = tp->sibling; |
|
808 |
traverse = TRAVERSE_DOWN; |
|
809 |
} else { |
|
810 |
tp = tp->parent; |
|
811 |
traverse = TRAVERSE_UP; |
|
812 |
} |
|
813 |
} |
|
814 |
} |
|
815 |
#endif |
|
816 | 792 |
|
817 | 793 |
return threads; |
818 | 794 |
} |
... | ... | |
870 | 846 |
aosShellAddCommand(&aos.shell, &_shellcmd_config); |
871 | 847 |
aosShellAddCommand(&aos.shell, &_shellcmd_info); |
872 | 848 |
aosShellAddCommand(&aos.shell, &_shellcmd_shutdown); |
873 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
849 |
#if (((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__)
|
|
874 | 850 |
aosShellAddCommand(&aos.shell, &_shellcmd_cpuload); |
875 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */
|
|
851 |
#endif /* ((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) && (CH_DBG_STATISTICS == TRUE) */
|
|
876 | 852 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) |
877 | 853 |
aosShellAddCommand(&aos.shell, &_shellcmd_kerneltest); |
878 | 854 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
core/src/aos_thread.c | ||
---|---|---|
103 | 103 |
} |
104 | 104 |
#endif /* (AMIROOS_CFG_DBG == true) && (CH_DBG_FILL_THREADS == TRUE) */ |
105 | 105 |
|
106 |
#if ((CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE)) || defined(__DOXYGEN__) |
|
107 |
|
|
108 |
/** |
|
109 |
* @brief Retrieve the first/root thread in the system. |
|
110 |
* |
|
111 |
* @return Pointer to the first/root thread. |
|
112 |
*/ |
|
113 |
thread_t* aosThreadGetFirst(void) |
|
114 |
{ |
|
115 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
116 |
return chRegFirstThread(); |
|
117 |
#elif (CH_CFG_USE_THREADHIERARCHY == TRUE) |
|
118 |
thread_t* tp = chThdGetSelfX(); |
|
119 |
while (tp->parent) { |
|
120 |
tp = tp->parent; |
|
121 |
} |
|
122 |
return tp; |
|
123 |
#endif |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* @brief Retrieve the next thread in the system. |
|
128 |
* |
|
129 |
* @param[in] thread Current thread to retrieve the 'successor' to. |
|
130 |
* |
|
131 |
* @return Pointer to the next thread, or NULL if there are no further threads. |
|
132 |
*/ |
|
133 |
thread_t* aosThreadGetNext(thread_t* thread) |
|
134 |
{ |
|
135 |
aosDbgCheck(thread != NULL); |
|
136 |
|
|
137 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
138 |
return chRegNextThread(thread); |
|
139 |
#elif (CH_CFG_USE_THREADHIERARCHY == TRUE) |
|
140 |
if (thread->children != NULL) { |
|
141 |
return thread->children; |
|
142 |
} else { |
|
143 |
while (thread != NULL && thread->sibling == NULL) { |
|
144 |
thread = thread->parent; |
|
145 |
} |
|
146 |
return (thread != NULL) ? thread->sibling : NULL; |
|
147 |
} |
|
148 |
#endif |
|
149 |
} |
|
150 |
|
|
151 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) || (CH_CFG_USE_THREADHIERARCHY == TRUE) */ |
|
152 |
|
|
106 | 153 |
/** @} */ |
modules/aos_chconf.h | ||
---|---|---|
165 | 165 |
* @note The default is @p TRUE. |
166 | 166 |
*/ |
167 | 167 |
#if !defined(CH_CFG_USE_TM) |
168 |
#define CH_CFG_USE_TM TRUE |
|
168 |
#if ((AMIROOS_CFG_DBG == true) || (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__) |
|
169 |
#define CH_CFG_USE_TM TRUE |
|
170 |
#else |
|
171 |
#define CH_CFG_USE_TM FALSE |
|
172 |
#endif |
|
169 | 173 |
#endif |
170 | 174 |
|
171 | 175 |
/** |
... | ... | |
270 | 274 |
* @details If enabled then the conditional variables APIs with timeout |
271 | 275 |
* specification are included in the kernel. |
272 | 276 |
* |
273 |
* @note The default is @p TRUE.
|
|
277 |
* @note The default is @p FALSE.
|
|
274 | 278 |
* @note Requires @p CH_CFG_USE_CONDVARS. |
275 | 279 |
*/ |
276 | 280 |
#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT) |
277 |
#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
|
|
281 |
#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE
|
|
278 | 282 |
#endif |
279 | 283 |
|
280 | 284 |
/** |
... | ... | |
492 | 496 |
* @note The default is @p FALSE. |
493 | 497 |
*/ |
494 | 498 |
#if !defined(CH_DBG_STATISTICS) |
495 |
#if ((CH_CFG_USE_TM == TRUE) && ((AMIROOS_CFG_DBG == true) || AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
|
|
499 |
#if ((CH_CFG_USE_TM == TRUE) && ((AMIROOS_CFG_DBG == true) || (AMIROOS_CFG_PROFILE == true))) || defined(__DOXYGEN__)
|
|
496 | 500 |
#define CH_DBG_STATISTICS TRUE |
497 | 501 |
#else |
498 | 502 |
#define CH_DBG_STATISTICS FALSE |
Also available in: Unified diff