RIOT-OS / RIOT

RIOT - The friendly OS for IoT
https://riot-os.org
GNU Lesser General Public License v2.1
4.95k stars 1.99k forks source link

drivers/periph: making bus drivers thread safe #2314

Closed haukepetersen closed 9 years ago

haukepetersen commented 9 years ago

As pointed out in #2289, our current bus driver implementations are not thread save. A solution is proposed in #2290 (for the STM32F4 cpu). If we use that proposed solution or if we do something else - either way we need to do this for all cpus and bus drivers. This issue is for tracking the implementation status of this effort.

Thread safe bus drivers:

Question: do we need to make the UART thread safe?

Edit [@thomaseichinger]: To keep things centralised I add a list of drivers needing adoption.

thomaseichinger commented 9 years ago

Question: do we need to make the UART thread safe?

If we are at it, let's do this.

thomaseichinger commented 9 years ago

Question: do we need to make the UART thread safe?

After thinking about it some more it would break usage of DEBUG() in ISR context and similar, so probably not. Other opinions?=

jnohlgard commented 9 years ago

@thomaseichinger Can it be avoided by letting the UART IRQ have a higher priority? To be able to transmit while another ISR is waiting for the lock?

haukepetersen commented 9 years ago

@gebart: I would not start with higher IRQ priorities - as for (i) some platforms do not support this and (ii) we have not really investigated if the kernel is actually able to run with different priorities (it's still an open task...).

But I think we could add a lock for the UART, but we can just not use it for stdout...

jnohlgard commented 9 years ago

I got an idea: Using atomic counters it should be possible to implement the UART buffering functions without locking, with the drawback that we may drop bytes when the buffer gets full.

haukepetersen commented 9 years ago

This would work if the UART driver would buffer... But it is explicitly designed not to buffer, as this is something intended to do by the higher-level modules put on top of the UART.

thomaseichinger commented 9 years ago

I updated the description to also include parts using the updated interfaces to track adoption.

jnohlgard commented 9 years ago

Just for completeness I added the kinets_common stuff still being worked on in #2265

jnohlgard commented 9 years ago

After #2326 was merged tonight I believe this can be closed as resolved.

PeterKietzmann commented 9 years ago

jap, correct