Functions to display current tasks and memory usage

rwel59
Posts: 97
Joined: Thu Oct 12, 2017 3:32 pm

Functions to display current tasks and memory usage

Postby rwel59 » Mon Apr 02, 2018 3:03 am

I thought that I had seen references to a couple of functions but having trouble finding them again (or maybe it was my imagination).

- Is there a function that I can call in code to determine what tasks are currently running, or at least if a specific (named) task is running

- Is there a function that I can monitor in code to track a specific task's memory consumption

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Functions to display current tasks and memory usage

Postby ESP_igrr » Mon Apr 02, 2018 3:27 am


rwel59
Posts: 97
Joined: Thu Oct 12, 2017 3:32 pm

Re: Functions to display current tasks and memory usage

Postby rwel59 » Mon Apr 02, 2018 11:44 am

I'm assuming that turning on the trace will impact size (and maybe performance)? Are there any non-debugging facilities available to get this info as part of 'normal' code operations?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Functions to display current tasks and memory usage

Postby kolban » Mon Apr 02, 2018 3:03 pm

If we take a look at the FreeRTOS underlying API called "vTaskList" ... see:

https://www.freertos.org/a00021.html#vTaskList

we see that FreeRTOS itself requires trace enabled.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: Functions to display current tasks and memory usage

Postby snahmad75 » Wed Dec 05, 2018 7:56 pm

Hi,

I tried vTaskList. It does not shows cpu usage in percentage.


printf( "Task Name\tStatus\tPrio\tHWM\tTask\tAffinity\n");
char stats_buffer[1024];
vTaskList(stats_buffer);
printf("%s\n", stats_buffer);

Thanks,
Naeem

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Functions to display current tasks and memory usage

Postby fly135 » Wed Dec 05, 2018 9:42 pm

snahmad75 wrote:
Wed Dec 05, 2018 7:56 pm
Hi,

I tried vTaskList. It does not shows cpu usage in percentage.


printf( "Task Name\tStatus\tPrio\tHWM\tTask\tAffinity\n");
char stats_buffer[1024];
vTaskList(stats_buffer);
printf("%s\n", stats_buffer);

Thanks,
Naeem
https://www.freertos.org/rtos-run-time-stats.html

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: Functions to display current tasks and memory usage

Postby snahmad75 » Wed Dec 05, 2018 10:22 pm

Hi,

I did use vTaskGetRunTimeStats() but was not pretty output.

Give me example to show CPU usage per thread with columns and tabular form.


Thanks,
Naeem

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: Functions to display current tasks and memory usage

Postby snahmad75 » Thu Jan 31, 2019 1:10 pm

Hi,

Kindly help please with nice pretty output of CPU stats.

I need to know CPU IDLE for both cpu0 and cpu1

Thanks,
Naeem

jagpreetw
Posts: 2
Joined: Thu Jan 31, 2019 1:41 pm

Re: Functions to display current tasks and memory usage

Postby jagpreetw » Thu Jan 31, 2019 1:45 pm

Hi

Can someone check my code for deep sleep. I am unable to get it below 9mA. Please help

#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 3 /* Time ESP32 will go to sleep (in seconds) */

RTC_DATA_ATTR int bootCount = 0;

int GREEN_LED_PIN = 25;
int YELLOW_LED_PIN = 26;

void setup(){

pinMode(GREEN_LED_PIN,OUTPUT);
pinMode(YELLOW_LED_PIN,OUTPUT);
delay(500);

if(bootCount == 0) //Run this only the first time
{
digitalWrite(YELLOW_LED_PIN,HIGH);
bootCount = bootCount+1;
}else
{
digitalWrite(GREEN_LED_PIN,HIGH);
}

delay(3000);

digitalWrite(GREEN_LED_PIN,LOW);
digitalWrite(YELLOW_LED_PIN,LOW);

esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_deep_sleep_start();
}

void loop(){

}

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 116 guests