diff --git a/APP_Framework/Applications/main.c b/APP_Framework/Applications/main.c index 54991e27b..b10557a97 100644 --- a/APP_Framework/Applications/main.c +++ b/APP_Framework/Applications/main.c @@ -15,108 +15,6 @@ // #include #include -pthread_mutex_t* get_memtest_mtx() { - static pthread_mutex_t mem_test_mtx; - return &mem_test_mtx; -} - - -extern void ShowMemory(); -void malloc_thread(void* size) -{ - int tid = GetKTaskDescriptor()->id.id; - int* tmp = (int*)size; - int malloc_size = *tmp; - - PrivMutexObtain(get_memtest_mtx()); - printf("TID: %d Working. size: %d\n", tid, malloc_size); - PrivMutexAbandon(get_memtest_mtx()); - - void* ptr_allocated = NULL; - while ((ptr_allocated = malloc(malloc_size)) != NULL) { - PrivMutexObtain(get_memtest_mtx()); - printf("\n[TID: %d]==================================================\n", tid); - ShowMemory(); - PrivMutexAbandon(get_memtest_mtx()); - } - - PrivMutexObtain(get_memtest_mtx()); - printf("TID: %d Exiting.\n", tid); - PrivMutexAbandon(get_memtest_mtx()); -} - -#include -int testMemMain() -{ - PrivMutexCreate(get_memtest_mtx(), NULL); - - int malloc_size = 10 * 1024; - int tid = KTaskCreate("mem1", malloc_thread, (void*)&malloc_size, 2048, 20); - StartupKTask(tid); - // malloc_thread(&malloc_size); - - - // void* ptr_allocated[5] = { NULL }; - // ptr_allocated[0] = malloc(malloc_size); - // printf("0x%x ==================================================\n", ptr_allocated[0]); - // ShowMemory(); - // ptr_allocated[1] = malloc(malloc_size); - // printf("0x%x ==================================================\n", ptr_allocated[1]); - // ShowMemory(); - - // malloc_size = 996; - // ptr_allocated[2] = malloc(malloc_size); - // printf("0x%x ==================================================\n", ptr_allocated[2]); - // ShowMemory(); - - // free(ptr_allocated[0]); - // printf("==================================================\n"); - // ShowMemory(); - // ptr_allocated[0] = malloc(malloc_size); - // printf("0x%x ==================================================\n", ptr_allocated[0]); - // ShowMemory(); - - // ptr_allocated[3] = malloc(malloc_size); - // free(ptr_allocated[2]); - // printf("0x%x ==================================================\n", ptr_allocated[3]); - // ShowMemory(); - - // malloc_size = 333; - // ptr_allocated[2] = malloc(malloc_size); - // ptr_allocated[4] = malloc(malloc_size); - // printf("0x%x ==================================================\n", ptr_allocated[2]); - // printf("0x%x ==================================================\n", ptr_allocated[4]); - // ShowMemory(); - - // free(ptr_allocated[0]); - // free(ptr_allocated[1]); - // free(ptr_allocated[2]); - // free(ptr_allocated[3]); - // free(ptr_allocated[4]); - - - int malloc_size2 = 1024; - int tid2 = KTaskCreate("mem2", malloc_thread, &malloc_size2, 2048, 20); - StartupKTask(tid2); - // malloc_thread(&malloc_size); - int malloc_size3 = 127; - int tid3 = KTaskCreate("mem3", malloc_thread, &malloc_size3, 2048, 20); - StartupKTask(tid3); - // malloc_thread(&malloc_size); - int malloc_size4 = 45; - int tid4 = KTaskCreate("mem4", malloc_thread, &malloc_size4, 2048, 20); - StartupKTask(tid4); - // malloc_thread(&malloc_size); - int malloc_size5 = 16; - int tid5 = KTaskCreate("mem5", malloc_thread, &malloc_size5, 2048, 20); - StartupKTask(tid5); - // malloc_thread(&malloc_size); - MdelayKTask(5000); - return 0; -} -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_PARAM_NUM(0), - testMemMain, testMemMain, list memory usage information); - extern int FrameworkInit(); extern void ApplicationOtaTaskInit(void); int main(void) diff --git a/Ubiquitous/XiZi_IIoT/kernel/memory/byte_manage.c b/Ubiquitous/XiZi_IIoT/kernel/memory/byte_manage.c index c2aef788e..3bf3144cb 100644 --- a/Ubiquitous/XiZi_IIoT/kernel/memory/byte_manage.c +++ b/Ubiquitous/XiZi_IIoT/kernel/memory/byte_manage.c @@ -793,7 +793,7 @@ void x_free(void *pointer) if (!ByteManager.dynamic_buddy_manager.done->JudgeLegal(&ByteManager.dynamic_buddy_manager, pointer)) { CriticalAreaUnLock(lock); - SYS_ERR("[%s] Freeing a no allocated address.\n", __func__); + SYS_ERR("[%s] Freeing a unallocated address.\n", __func__); return; }