From ee02d995fec9b1ce751e671b28641771746ee2fe Mon Sep 17 00:00:00 2001 From: Gabriel Staples Date: Wed, 8 May 2024 15:26:55 -0700 Subject: [PATCH 1/3] list.c: improve documentation about initializing binary semaphores --- list.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/list.c b/list.c index fc99538b24..05f26a683a 100644 --- a/list.c +++ b/list.c @@ -184,6 +184,15 @@ void vListInsert( List_t * const pxList, * 4) Using a queue or semaphore before it has been initialised or * before the scheduler has been started (are interrupts firing * before vTaskStartScheduler() has been called?). + * - This includes initializing binary semaphores before taking them. If + * you create one with `xSemaphoreCreateBinary()` or + * `xSemaphoreCreateBinaryStatic()`, you must call `xSemaphoreGive()` + * before calling `xSemaphoreTake(). See: + * https://freertos.org/xSemaphoreCreateBinaryStatic.html: + * > The semaphore is created in the 'empty' state, meaning the + * > semaphore must first be given using the xSemaphoreGive() API + * > function before it can subsequently be taken (obtained) using the + * > xSemaphoreTake() function. * 5) If the FreeRTOS port supports interrupt nesting then ensure that * the priority of the tick interrupt is at or below * configMAX_SYSCALL_INTERRUPT_PRIORITY. From b67980cc2ce9cad3c8274498a6658b75c4a52111 Mon Sep 17 00:00:00 2001 From: Gabriel Staples Date: Wed, 8 May 2024 15:34:59 -0700 Subject: [PATCH 2/3] list.c: add comment --- list.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/list.c b/list.c index 05f26a683a..5e8649a160 100644 --- a/list.c +++ b/list.c @@ -201,7 +201,9 @@ void vListInsert( List_t * const pxList, for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) { /* There is nothing to do here, just iterating to the wanted - * insertion position. */ + * insertion position. + * IF YOU FIND YOUR CODE STUCK HERE, SEE THE NOTE JUST ABOVE. + */ } } From 36f4ffee9e1d2e8a04be96c2a43b2023ef329250 Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Mon, 13 May 2024 10:54:41 +0000 Subject: [PATCH 3/3] Code review suggestions Signed-off-by: Gaurav Aggarwal --- list.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/list.c b/list.c index 5e8649a160..e6dbaaa3ab 100644 --- a/list.c +++ b/list.c @@ -184,16 +184,14 @@ void vListInsert( List_t * const pxList, * 4) Using a queue or semaphore before it has been initialised or * before the scheduler has been started (are interrupts firing * before vTaskStartScheduler() has been called?). - * - This includes initializing binary semaphores before taking them. If - * you create one with `xSemaphoreCreateBinary()` or - * `xSemaphoreCreateBinaryStatic()`, you must call `xSemaphoreGive()` - * before calling `xSemaphoreTake(). See: - * https://freertos.org/xSemaphoreCreateBinaryStatic.html: - * > The semaphore is created in the 'empty' state, meaning the - * > semaphore must first be given using the xSemaphoreGive() API - * > function before it can subsequently be taken (obtained) using the - * > xSemaphoreTake() function. - * 5) If the FreeRTOS port supports interrupt nesting then ensure that + * 5) Attempting to 'take' binary semaphores created using + * `xSemaphoreCreateBinary()` or `xSemaphoreCreateBinaryStatic()` + * APIs, before 'giving' them. Binary semaphores created using + * `xSemaphoreCreateBinary()` or `xSemaphoreCreateBinaryStatic()`, + * are created in a state such that the semaphore must first be + * 'given' using xSemaphoreGive() API before it can be 'taken' using + * xSemaphoreTake() API. + * 6) If the FreeRTOS port supports interrupt nesting then ensure that * the priority of the tick interrupt is at or below * configMAX_SYSCALL_INTERRUPT_PRIORITY. **********************************************************************/ @@ -201,7 +199,7 @@ void vListInsert( List_t * const pxList, for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) { /* There is nothing to do here, just iterating to the wanted - * insertion position. + * insertion position. * IF YOU FIND YOUR CODE STUCK HERE, SEE THE NOTE JUST ABOVE. */ }