@@ -345,6 +345,33 @@ DMOD_BUILTIN_API( dmosi, 1.0, dmosi_process_t, _process_get_parent, (dmosi_proce
345345 */
346346typedef void (* dmosi_thread_entry_t )(void * arg );
347347
348+ /**
349+ * @brief Thread state enumeration
350+ */
351+ typedef enum {
352+ DMOSI_THREAD_STATE_CREATED , /**< Thread created but not started */
353+ DMOSI_THREAD_STATE_READY , /**< Thread is ready to run */
354+ DMOSI_THREAD_STATE_RUNNING , /**< Thread is currently running */
355+ DMOSI_THREAD_STATE_BLOCKED , /**< Thread is blocked (waiting for resource) */
356+ DMOSI_THREAD_STATE_SUSPENDED , /**< Thread is suspended */
357+ DMOSI_THREAD_STATE_TERMINATED /**< Thread has terminated */
358+ } dmosi_thread_state_t ;
359+
360+ /**
361+ * @brief Thread information structure
362+ *
363+ * This structure holds auxiliary information about a thread, including
364+ * stack usage statistics, state, CPU usage, and runtime.
365+ */
366+ typedef struct {
367+ size_t stack_total ; /**< Total stack size in bytes */
368+ size_t stack_current ; /**< Current stack usage in bytes */
369+ size_t stack_peak ; /**< Peak stack usage in bytes */
370+ dmosi_thread_state_t state ; /**< Current thread state */
371+ float cpu_usage ; /**< CPU usage as a percentage (0.0 - 100.0) */
372+ uint64_t runtime_ms ; /**< Thread runtime in milliseconds */
373+ } dmosi_thread_info_t ;
374+
348375/**
349376 * @brief Create a thread
350377 *
@@ -467,6 +494,18 @@ DMOD_BUILTIN_API( dmosi, 1.0, size_t, _thread_get_all, (dmosi_thread_t* threads,
467494 */
468495DMOD_BUILTIN_API ( dmosi , 1.0 , size_t , _thread_get_by_process , (dmosi_process_t process , dmosi_thread_t * threads , size_t max_count ) );
469496
497+ /**
498+ * @brief Get information about a thread
499+ *
500+ * Fills the provided @p info structure with auxiliary information about
501+ * @p thread, including stack usage statistics, state, CPU usage, and runtime.
502+ *
503+ * @param thread Thread handle (if NULL, returns info for the current thread)
504+ * @param info Pointer to a dmosi_thread_info_t structure to fill
505+ * @return int 0 on success, negative error code on failure
506+ */
507+ DMOD_BUILTIN_API ( dmosi , 1.0 , int , _thread_get_info , (dmosi_thread_t thread , dmosi_thread_info_t * info ) );
508+
470509/** @} */ // end of DMOSI_THREAD_API
471510
472511//==============================================================================
0 commit comments