Open morgoob opened 10 months ago
The blinkLED task calls xSemaphoreGive(mutex) without having acquired the mutex using xSemaphoreTake(mutex, portMAX_DELAY) first, causing a system reboot (due to failed assertion) after the delay value is entered by a user.
xSemaphoreGive(mutex)
xSemaphoreTake(mutex, portMAX_DELAY)
Here is the output of the original solution:
---FreeRTOS Mutex Solution--- Enter a number for delay (milliseconds) Sending: 50 assert failed: xQueueGenericSend queue.c:832 (pxQueue->pcHead != ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle()) assert failed: xQueueGenericSend queue.c:832 (pxQueue->pcHead != ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle()) Backtrace: 0x400881a7:0x3ffbb0a0 0x400833dc:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 |<-CONTINUES ELF file SHA256: 42aaf96fb649f818 Rebooting... ets Jul 29 2019 12:21:46 rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:1184 load:0x40078000,len:13260 load:0x40080400,len:3028 entry 0x400805e4
Here is the output with my fix:
---FreeRTOS Mutex Solution--- Enter a number for delay (milliseconds) Sending: 250 Received: 250 Done!
Pull Request Description
Issue
The blinkLED task calls
xSemaphoreGive(mutex)
without having acquired the mutex usingxSemaphoreTake(mutex, portMAX_DELAY)
first, causing a system reboot (due to failed assertion) after the delay value is entered by a user.Output
Here is the output of the original solution:
Here is the output with my fix: