Page 1 of 1

Functions to display current tasks and memory usage

Posted: Mon Apr 02, 2018 3:03 am
by rwel59
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

Re: Functions to display current tasks and memory usage

Posted: Mon Apr 02, 2018 3:27 am
by ESP_igrr

Re: Functions to display current tasks and memory usage

Posted: Mon Apr 02, 2018 11:44 am
by rwel59
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?

Re: Functions to display current tasks and memory usage

Posted: Mon Apr 02, 2018 3:03 pm
by kolban
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.

Re: Functions to display current tasks and memory usage

Posted: Wed Dec 05, 2018 7:56 pm
by snahmad75
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

Re: Functions to display current tasks and memory usage

Posted: Wed Dec 05, 2018 9:42 pm
by fly135
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

Re: Functions to display current tasks and memory usage

Posted: Wed Dec 05, 2018 10:22 pm
by snahmad75
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

Re: Functions to display current tasks and memory usage

Posted: Thu Jan 31, 2019 1:10 pm
by snahmad75
Hi,

Kindly help please with nice pretty output of CPU stats.

I need to know CPU IDLE for both cpu0 and cpu1

Thanks,
Naeem

Re: Functions to display current tasks and memory usage

Posted: Thu Jan 31, 2019 1:45 pm
by jagpreetw
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(){

}