Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Lập trình hệ thống nhúng, Kỹ thuật lập trình, Nguồn thông điệp LCD | ARM PROGRAMMING Bùi Qu c B o Standard malloc and free function They are not always available on small embedded systems. Their implementation can be relatively large so take up valuable code space. They are rarely thread safe. They are not deterministic. The amount of time taken to execute the functions will differ from call to call. They can suffer from memory fragmentation. They can complicate the linker configuration. BÙI QU C B O 1 FreeRTOS pvPortMalloc() and vPortFree() FreeRTOS cung c p 2 hàm pvPortMalloc() và pvPortFree() User có th vi t l i hai hàm này Hai hàm này n m trong các file heap_1.c, heap_2.c and heap_3.c, trong thư m c FreeRTOS\Source\Portable\MemMang Heap_1.c Heap1.c cung c p m t hàm pvPortMalloc() cơ b n, không có hàm pvPortFree() Các chương trình mà không có l nh xóa task, semaphore, queue thì có th dùng heap1.c BÙI QU C B O 2 Heap2.c Heap1.c cung c p hàm pvPortMalloc() và pvPortFree() BÙI QU C B O 3 Heap3.c Heap3.c dùng các hàm malloc và free, ñ ng th i suspend scheduler BÙI QU C B O 4 void *pvPortMalloc( size_t xWantedSize ) { void *pvReturn; vTaskSuspendAll(); { pvReturn = malloc( xWantedSize ); } xTaskResumeAll(); return pvReturn; } void vPortFree( void *pv ) { if( pv != NULL ) { vTaskSuspendAll(); { free( pv ); } xTaskResumeAll(); } } BÙI QU C B .