Skip to content

Add thread info API (stack usage, state, CPU usage, runtime)#22

Merged
JohnAmadis merged 2 commits intomainfrom
copilot/add-thread-info-api
Feb 22, 2026
Merged

Add thread info API (stack usage, state, CPU usage, runtime)#22
JohnAmadis merged 2 commits intomainfrom
copilot/add-thread-info-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 22, 2026

No API existed to query auxiliary per-thread diagnostics such as stack utilization, thread state, CPU load, or uptime.

New types

  • dmosi_thread_state_t — enum covering CREATED, READY, RUNNING, BLOCKED, SUSPENDED, TERMINATED
  • dmosi_thread_info_t — aggregate struct:
    typedef struct {
        size_t               stack_total;    /* total stack size in bytes        */
        size_t               stack_current;  /* current stack usage in bytes     */
        size_t               stack_peak;     /* peak stack usage in bytes        */
        dmosi_thread_state_t state;          /* current thread state             */
        float                cpu_usage;      /* CPU usage, 0.0–100.0 %          */
        uint64_t             runtime_ms;     /* thread uptime in milliseconds    */
    } dmosi_thread_info_t;

New API

DMOD_BUILTIN_API( dmosi, 1.0, int, _thread_get_info,
    (dmosi_thread_t thread, dmosi_thread_info_t* info) );
  • thread == NULL → query current thread (consistent with other _thread_get_* functions)
  • info == NULL → returns -EINVAL
  • Weak default implementation zeroes the struct and returns -ENOSYS; RTOS ports override with real data
Original prompt

This section details on the original issue you should resolve

<issue_title>Dodać API do pobierania informacji na temat wątków</issue_title>
<issue_description>Potrzebne jest API, które pozwoli pobrać strukturę, w której będą przechowywane informacje pomocnicze na temat wątków, takie jak:

  1. Całkowity rozmiar stosu
  2. Aktualne zużycie stosu
  3. Szczytowe zużycie stosu
  4. Stan wątku
  5. CPU usage
  6. Czas działania wątku</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…_thread_get_info

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add API for retrieving thread information Add thread info API (stack usage, state, CPU usage, runtime) Feb 22, 2026
Copilot AI requested a review from JohnAmadis February 22, 2026 20:25
@JohnAmadis JohnAmadis marked this pull request as ready for review February 22, 2026 20:34
@JohnAmadis JohnAmadis merged commit 00524a5 into main Feb 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dodać API do pobierania informacji na temat wątków

2 participants