我在FreeRTOS (FreeRTOSV7.4.0\FreeRTOS\Source\tasks.c)中找到了一些代码:
void vTaskSuspendAll( void )
{
/* A critical section is not required as the variable is of type
portBASE_TYPE. */
++uxSchedulerSuspended;
}
明确表示不需要保护,因为类型是"portBASE_TYPE",是"long“类型。我的理解是,它假定此类型的自我增量是原子的。但在我反汇编后,我找不到任何证据,这是一个简单的加载->添加->存储。那这是个问题吗?
void vTaskSuspendAll( void )
{
/* A critical section is not required as the variable is of type
portBASE_TYPE. */
++uxSchedulerSuspended;
4dc: 4b03 ldr r3, [pc, #12] ; (4ec <vTaskSuspendAll+0x10>)
4de: f8d3 2118 ldr.w r2, [r3, #280] ; 0x118
4e2: 1c50 adds r0, r2, #1
4e4: f8c3 0118 str.w r0, [r3, #280] ; 0x118
4e8: 4770 bx lr
4ea: bf00 nop
4ec: 00000000 .word 0x00000000
000004f0 <xTaskGetTickCount>:
return xAlreadyYielded;
}
https://stackoverflow.com/questions/15513622
复制相似问题