2021-01-08 05:10 AM
Hi!
So I was reading the wiki here https://wiki.st.com/stm32mpu/wiki/How_to_configure_system_resources
and they tell you to use PERIPH_LOCK, which is a function that can be found here:
However, HAL_HSEM_FastTake does a read lock and not a write lock.
When should I be using HAL_HSEM_FastTake() vs HAL_HSEM_Take()? Why does PERIPH_LOCK call HAL_HSEM_FastTake() to get a read lock when it is writing to GPIO/EXTI registers?
2021-01-11 06:46 AM
Hi @AMurr.2282 ,
Reading the RM again, I understand you probably make a confusion between the 2 lock methods "label" (read) or (write) and the operation to protect.
Once semaphore is taken it lock peripheral registers whatever access type.
But there's 2 ways to lock :
– 2-step lock: by writing COREID and PROCID to the semaphore, followed by a read check -> labeled (write)
– 1-step lock: by reading the COREID from the semaphore -> labeled (read) method
I supposed advantage of "read" method is to be atomic.
Is that sound clearer ?
Olivier
2021-01-11 06:53 AM
> Is that sound clearer ?
Not really. In what situation would I need to use a write lock and why?
2021-01-12 07:11 AM
Hi @AMurr.2282 ,
Difference between 2-step (write) and 1-setp (read) is mentioned in RM :
"There is no PROCID available with the 1- step (read) lock" -> you can't identify the process which take the semaphore, only the COREID.
So, to arbitrate multi-process concurrency on same core, it can be more convenient to use the 2-step method.
Olivier