9 years, 4 months ago.

DigitalOut Concurrency Issues?

I just had a terrifying thought... Is it possible for there to be concurrency issues with driving multiple DigitalOut's that happen to be on the same port from different threads/ISRs?

Question relating to:

Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard. cmsis, rtos, RTX

1 Answer

9 years, 4 months ago.

Wait, halloween is over, right? Stop trying to scare me :(.

I am afraid there is no special protection against this. Now writing should be fine I think, since every (or most?) target I am aware of uses a special set/clear register: So since it is just writing a bit it should go fine I think.

However for example switching from input to output, is reading a register, settnig a bit, and writing it again. If it interrupts between the reading and writing part, then yes it will go wrong.

Accepted Answer

Alright. I think instantiation is unsafe too, so I should probably make all my DigitalOut's global instead of locally created on the Threads stack.

posted by Neil Thiessen 04 Dec 2014