mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
multi_heap: use portENTER/EXIT_CRITICAL instead of taskENTER/EXIT_CRITICAL
This commit is contained in:
committed by
Mahavir Jain
parent
f65870566a
commit
573ea385b4
@@ -77,7 +77,7 @@ esp_err_t heap_trace_start(heap_trace_mode_t mode_param)
|
|||||||
if (buffer == NULL || total_records == 0) {
|
if (buffer == NULL || total_records == 0) {
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
taskENTER_CRITICAL(&trace_mux);
|
portENTER_CRITICAL(&trace_mux);
|
||||||
|
|
||||||
tracing = false;
|
tracing = false;
|
||||||
mode = mode_param;
|
mode = mode_param;
|
||||||
@@ -87,7 +87,7 @@ esp_err_t heap_trace_start(heap_trace_mode_t mode_param)
|
|||||||
has_overflowed = false;
|
has_overflowed = false;
|
||||||
heap_trace_resume();
|
heap_trace_resume();
|
||||||
|
|
||||||
taskEXIT_CRITICAL(&trace_mux);
|
portEXIT_CRITICAL(&trace_mux);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,13 +128,13 @@ esp_err_t heap_trace_get(size_t index, heap_trace_record_t *record)
|
|||||||
}
|
}
|
||||||
esp_err_t result = ESP_OK;
|
esp_err_t result = ESP_OK;
|
||||||
|
|
||||||
taskENTER_CRITICAL(&trace_mux);
|
portENTER_CRITICAL(&trace_mux);
|
||||||
if (index >= count) {
|
if (index >= count) {
|
||||||
result = ESP_ERR_INVALID_ARG; /* out of range for 'count' */
|
result = ESP_ERR_INVALID_ARG; /* out of range for 'count' */
|
||||||
} else {
|
} else {
|
||||||
memcpy(record, &buffer[index], sizeof(heap_trace_record_t));
|
memcpy(record, &buffer[index], sizeof(heap_trace_record_t));
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL(&trace_mux);
|
portEXIT_CRITICAL(&trace_mux);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ void heap_trace_dump(void)
|
|||||||
/* Add a new allocation to the heap trace records */
|
/* Add a new allocation to the heap trace records */
|
||||||
static IRAM_ATTR void record_allocation(const heap_trace_record_t *record)
|
static IRAM_ATTR void record_allocation(const heap_trace_record_t *record)
|
||||||
{
|
{
|
||||||
taskENTER_CRITICAL(&trace_mux);
|
portENTER_CRITICAL(&trace_mux);
|
||||||
if (tracing) {
|
if (tracing) {
|
||||||
if (count == total_records) {
|
if (count == total_records) {
|
||||||
has_overflowed = true;
|
has_overflowed = true;
|
||||||
@@ -211,7 +211,7 @@ static IRAM_ATTR void record_allocation(const heap_trace_record_t *record)
|
|||||||
count++;
|
count++;
|
||||||
total_allocations++;
|
total_allocations++;
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL(&trace_mux);
|
portEXIT_CRITICAL(&trace_mux);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove a record, used when freeing
|
// remove a record, used when freeing
|
||||||
@@ -224,7 +224,7 @@ static void remove_record(int index);
|
|||||||
*/
|
*/
|
||||||
static IRAM_ATTR void record_free(void *p, void **callers)
|
static IRAM_ATTR void record_free(void *p, void **callers)
|
||||||
{
|
{
|
||||||
taskENTER_CRITICAL(&trace_mux);
|
portENTER_CRITICAL(&trace_mux);
|
||||||
if (tracing && count > 0) {
|
if (tracing && count > 0) {
|
||||||
total_frees++;
|
total_frees++;
|
||||||
/* search backwards for the allocation record matching this free */
|
/* search backwards for the allocation record matching this free */
|
||||||
@@ -244,7 +244,7 @@ static IRAM_ATTR void record_free(void *p, void **callers)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL(&trace_mux);
|
portEXIT_CRITICAL(&trace_mux);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove the entry at 'index' from the ringbuffer of saved records */
|
/* remove the entry at 'index' from the ringbuffer of saved records */
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
|
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
|
||||||
#include <rom/ets_sys.h>
|
#include <rom/ets_sys.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@@ -24,14 +23,14 @@
|
|||||||
we need to use portmux spinlocks here not RTOS mutexes */
|
we need to use portmux spinlocks here not RTOS mutexes */
|
||||||
#define MULTI_HEAP_LOCK(PLOCK) do { \
|
#define MULTI_HEAP_LOCK(PLOCK) do { \
|
||||||
if((PLOCK) != NULL) { \
|
if((PLOCK) != NULL) { \
|
||||||
taskENTER_CRITICAL((portMUX_TYPE *)(PLOCK)); \
|
portENTER_CRITICAL((portMUX_TYPE *)(PLOCK)); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
#define MULTI_HEAP_UNLOCK(PLOCK) do { \
|
#define MULTI_HEAP_UNLOCK(PLOCK) do { \
|
||||||
if ((PLOCK) != NULL) { \
|
if ((PLOCK) != NULL) { \
|
||||||
taskEXIT_CRITICAL((portMUX_TYPE *)(PLOCK)); \
|
portEXIT_CRITICAL((portMUX_TYPE *)(PLOCK)); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user