|
48 | 48 | * stdio (printf() and friends) should be called from a single task
|
49 | 49 | * only or serialized with a FreeRTOS primitive such as a binary
|
50 | 50 | * semaphore or mutex.
|
51 |
| -* |
52 |
| -* Note: When using LLDB (the default debugger on macOS) with this port, |
| 51 | +* |
| 52 | +* Note: When using LLDB (the default debugger on macOS) with this port, |
53 | 53 | * suppress SIGUSR1 to prevent debugger interference. This can be
|
54 | 54 | * done by adding the following line to ~/.lldbinit:
|
55 | 55 | * `process handle SIGUSR1 -n true -p false -s false`
|
@@ -324,17 +324,23 @@ BaseType_t xPortStartScheduler( void )
|
324 | 324 | void vPortEndScheduler( void )
|
325 | 325 | {
|
326 | 326 | Thread_t * pxCurrentThread;
|
| 327 | + BaseType_t xIsFreeRTOSThread; |
327 | 328 |
|
328 | 329 | /* Stop the timer tick thread. */
|
329 | 330 | xTimerTickThreadShouldRun = false;
|
330 | 331 | pthread_join( hTimerTickThread, NULL );
|
331 | 332 |
|
| 333 | + /* Check whether the current thread is a FreeRTOS thread. |
| 334 | + * This has to happen before the scheduler is signaled to exit |
| 335 | + * its loop to prevent data races on the thread key. */ |
| 336 | + xIsFreeRTOSThread = prvIsFreeRTOSThread(); |
| 337 | + |
332 | 338 | /* Signal the scheduler to exit its loop. */
|
333 | 339 | xSchedulerEnd = pdTRUE;
|
334 | 340 | ( void ) pthread_kill( hMainThread, SIG_RESUME );
|
335 | 341 |
|
336 | 342 | /* Waiting to be deleted here. */
|
337 |
| - if( prvIsFreeRTOSThread() == pdTRUE ) |
| 343 | + if( xIsFreeRTOSThread == pdTRUE ) |
338 | 344 | {
|
339 | 345 | pxCurrentThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
340 | 346 | event_wait( pxCurrentThread->ev );
|
|
0 commit comments