Revision aed3754b core/src/aos_thread.c
core/src/aos_thread.c | ||
---|---|---|
57 | 57 |
return; |
58 | 58 |
} |
59 | 59 |
|
60 |
#if (CH_DBG_FILL_THREADS == TRUE) || defined(__DOXYGEN__) |
|
61 |
/** |
|
62 |
* @brief Calculate the peak stack utilization for a specific thread so far in bytes. |
|
63 |
* |
|
64 |
* @param[in] thread Thread to calculate the stack utilization for. |
|
65 |
* |
|
66 |
* @return Absolute peak stack utilization in bytes. |
|
67 |
*/ |
|
68 |
size_t aosThdGetStackPeakUtilization(thread_t* thread) |
|
69 |
{ |
|
70 |
aosDbgCheck(thread != NULL); |
|
71 |
|
|
72 |
size_t util; |
|
73 |
uint8_t* ptr = (uint8_t*)thread->wabase; |
|
74 |
|
|
75 |
chSysLock(); |
|
76 |
while (*ptr == CH_DBG_STACK_FILL_VALUE && ptr < (uint8_t*)thread->wabase + aosThdGetStacksize(thread)) { |
|
77 |
++ptr; |
|
78 |
} |
|
79 |
util = aosThdGetStacksize(thread) - (ptr - (uint8_t*)thread->wabase); |
|
80 |
chSysUnlock(); |
|
81 |
|
|
82 |
return util; |
|
83 |
} |
|
84 |
#endif /* CH_DBG_FILL_THREADS == TRUE */ |
|
85 |
|
|
60 | 86 |
/** @} */ |
Also available in: Unified diff