|
81 | 81 |
|
82 | 82 | #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) |
83 | 83 |
|
84 | | - static void prvTaskDeleteWithCapsTask( void * pvParameters ) |
| 84 | + static void prvTaskDeleteWithCaps( TaskHandle_t xTaskToDelete ) |
85 | 85 | { |
86 | | - TaskHandle_t xTaskToDelete = ( TaskHandle_t ) pvParameters; |
| 86 | + /* Return value unused if asserts are disabled */ |
| 87 | + BaseType_t __attribute__( ( unused ) ) xResult; |
| 88 | + StaticTask_t * pxTaskBuffer; |
| 89 | + StackType_t * puxStackBuffer; |
| 90 | + |
| 91 | + /* The task to be deleted must not be running. |
| 92 | + * So we suspend the task before deleting it. */ |
| 93 | + vTaskSuspend( xTaskToDelete ); |
| 94 | + |
| 95 | + /* Wait for the task to be suspended */ |
| 96 | + while( eRunning == eTaskGetState( xTaskToDelete ) ) |
| 97 | + { |
| 98 | + taskYIELD(); |
| 99 | + } |
87 | 100 |
|
88 | | - /* The task to be deleted must not be running */ |
89 | 101 | configASSERT( eRunning != eTaskGetState( xTaskToDelete ) ); |
90 | 102 |
|
| 103 | + xResult = xTaskGetStaticBuffers( xTaskToDelete, &puxStackBuffer, &pxTaskBuffer ); |
| 104 | + configASSERT( xResult == pdTRUE ); |
| 105 | + configASSERT( puxStackBuffer != NULL ); |
| 106 | + configASSERT( pxTaskBuffer != NULL ); |
| 107 | + |
| 108 | + /* We can delete the task and free the memory buffers. */ |
| 109 | + vTaskDelete( xTaskToDelete ); |
| 110 | + |
| 111 | + /* Free the memory buffers */ |
| 112 | + heap_caps_free( puxStackBuffer ); |
| 113 | + vPortFree( pxTaskBuffer ); |
| 114 | + } |
| 115 | + |
| 116 | + static void prvTaskDeleteWithCapsTask( void * pvParameters ) |
| 117 | + { |
| 118 | + TaskHandle_t xTaskToDelete = ( TaskHandle_t ) pvParameters; |
| 119 | + |
91 | 120 | /* Delete the WithCaps task */ |
92 | | - vTaskDeleteWithCaps( xTaskToDelete ); |
| 121 | + prvTaskDeleteWithCaps( xTaskToDelete ); |
93 | 122 |
|
94 | 123 | /* Delete the temporary clean up task */ |
95 | 124 | vTaskDelete( NULL ); |
|
98 | 127 | void vTaskDeleteWithCaps( TaskHandle_t xTaskToDelete ) |
99 | 128 | { |
100 | 129 | /* THIS FUNCTION SHOULD NOT BE CALLED FROM AN INTERRUPT CONTEXT. */ |
101 | | - /*TODO: Update it to use portASSERT_IF_IN_ISR() instead. (IDF-10540) */ |
| 130 | + /* TODO: Update it to use portASSERT_IF_IN_ISR() instead. (IDF-10540) */ |
102 | 131 | vPortAssertIfInISR(); |
103 | 132 |
|
104 | 133 | TaskHandle_t xCurrentTaskHandle = xTaskGetCurrentTaskHandle(); |
|
151 | 180 | } |
152 | 181 | } |
153 | 182 |
|
154 | | - #if ( configNUM_CORES > 1 ) |
155 | | - else if( eRunning == eTaskGetState( xTaskToDelete ) ) |
156 | | - { |
157 | | - /* The WithCaps task is running on another core. |
158 | | - * We suspend the task first and then delete it. */ |
159 | | - vTaskSuspend( xTaskToDelete ); |
160 | | - |
161 | | - /* Wait for the task to be suspended */ |
162 | | - while( eRunning == eTaskGetState( xTaskToDelete ) ) |
163 | | - { |
164 | | - portYIELD_WITHIN_API(); |
165 | | - } |
166 | | - |
167 | | - // Return value unused if asserts are disabled |
168 | | - BaseType_t __attribute__((unused)) xResult; |
169 | | - StaticTask_t * pxTaskBuffer; |
170 | | - StackType_t * puxStackBuffer; |
171 | | - |
172 | | - xResult = xTaskGetStaticBuffers( xTaskToDelete, &puxStackBuffer, &pxTaskBuffer ); |
173 | | - configASSERT( xResult == pdTRUE ); |
174 | | - configASSERT( puxStackBuffer != NULL ); |
175 | | - configASSERT( pxTaskBuffer != NULL ); |
176 | | - |
177 | | - /* Delete the task */ |
178 | | - vTaskDelete( xTaskToDelete ); |
179 | | - |
180 | | - /* Free the memory buffers */ |
181 | | - heap_caps_free( puxStackBuffer ); |
182 | | - vPortFree( pxTaskBuffer ); |
183 | | - } |
184 | | - #endif /* if ( configNUM_CORES > 1 ) */ |
185 | | - else |
186 | | - { |
187 | | - /* The WithCaps task is not running and is being deleted |
188 | | - * from another task's context. */ |
189 | | - configASSERT( eRunning != eTaskGetState( xTaskToDelete ) ); |
190 | | - |
191 | | - // Return value unused if asserts are disabled |
192 | | - BaseType_t __attribute__((unused)) xResult; |
193 | | - StaticTask_t * pxTaskBuffer; |
194 | | - StackType_t * puxStackBuffer; |
195 | | - |
196 | | - xResult = xTaskGetStaticBuffers( xTaskToDelete, &puxStackBuffer, &pxTaskBuffer ); |
197 | | - configASSERT( xResult == pdTRUE ); |
198 | | - configASSERT( puxStackBuffer != NULL ); |
199 | | - configASSERT( pxTaskBuffer != NULL ); |
200 | | - |
201 | | - /* We can delete the task and free the memory buffers. */ |
202 | | - vTaskDelete( xTaskToDelete ); |
203 | | - |
204 | | - /* Free the memory buffers */ |
205 | | - heap_caps_free( puxStackBuffer ); |
206 | | - vPortFree( pxTaskBuffer ); |
207 | | - } /* if( ( xTaskToDelete == NULL ) || ( xTaskToDelete == xCurrentTaskHandle ) ) */ |
| 183 | + /* Delete the WithCaps task */ |
| 184 | + prvTaskDeleteWithCaps( xTaskToDelete ); |
208 | 185 | } |
209 | 186 |
|
210 | 187 | #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ |
|
262 | 239 |
|
263 | 240 | void vQueueDeleteWithCaps( QueueHandle_t xQueue ) |
264 | 241 | { |
265 | | - // Return value unused if asserts are disabled |
266 | | - BaseType_t __attribute__((unused)) xResult; |
| 242 | + /* Return value unused if asserts are disabled */ |
| 243 | + BaseType_t __attribute__( ( unused ) ) xResult; |
267 | 244 | StaticQueue_t * pxQueueBuffer; |
268 | 245 | uint8_t * pucQueueStorageBuffer; |
269 | 246 |
|
|
335 | 312 |
|
336 | 313 | void vSemaphoreDeleteWithCaps( SemaphoreHandle_t xSemaphore ) |
337 | 314 | { |
338 | | - // Return value unused if asserts are disabled |
339 | | - BaseType_t __attribute__((unused)) xResult; |
| 315 | + /* Return value unused if asserts are disabled */ |
| 316 | + BaseType_t __attribute__( ( unused ) ) xResult; |
340 | 317 | StaticSemaphore_t * pxSemaphoreBuffer; |
341 | 318 |
|
342 | 319 | /* Retrieve the buffer used to create the semaphore before deleting it |
|
408 | 385 | void vStreamBufferGenericDeleteWithCaps( StreamBufferHandle_t xStreamBuffer, |
409 | 386 | BaseType_t xIsMessageBuffer ) |
410 | 387 | { |
411 | | - // Return value unused if asserts are disabled |
412 | | - BaseType_t __attribute__((unused)) xResult; |
| 388 | + /* Return value unused if asserts are disabled */ |
| 389 | + BaseType_t __attribute__( ( unused ) ) xResult; |
413 | 390 | StaticStreamBuffer_t * pxStaticStreamBuffer; |
414 | 391 | uint8_t * pucStreamBufferStorageArea; |
415 | 392 |
|
|
0 commit comments