SMP portGET_ISR_LOCK() context


I was porting to SMP v11 FreeRTOS Kernel. My question is regarding portGET_ISR_LOCK() and portRELEASE_ISR_LOCK(). Can they be called from the isr context or will they always be called from the non-isr context?

As such is it fine to implement them from Freertos’s recursive semaphore?


It can be called from ISR context also. One such example - FreeRTOS-Kernel/tasks.c at main · FreeRTOS/FreeRTOS-Kernel · GitHub.

This lock is supposed to provide inter-core synchronization and therefore, cannot be implemented using FreeRTOS synchronization primitives. Usually it is implemented using hardware spin lock. You can refer the following examples:

I looked at the examples you mentioned. XCoreAI implements it using a proprietary function, so that’s not really helpful while RP2040 gave some insight.

I am trying to port to arm R8. But judging from its specifications, it does not have any hardware spinlock. What do you suggest in this case?

I also looked at FreeRTOS-Kernel-Partner-Supported-Ports/TI/CORTEX_A53_64-BIT_TI_AM64_SMP at d38f59dbcdfabbe71361764e194e1ad6202f902c · FreeRTOS/FreeRTOS-Kernel-Partner-Supported-Ports · GitHub, but could not understand if the spinlock utilizes hardware lock or some other mechanism.

It uses Load Exclusive and Store Exclusive instructions:

Oh! I understand now. Thanks