Is it necessary to ensure the thread-safety when writing a device driver?
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Nov 14 13:39:36 UTC 2008
Hi,
many BSPs use the termios framework for the console driver. This
framework takes care about concurrent access. For a particular simple
console driver see in the ARM BSP lpc24xx.
PowerMan wrote:
> I am writing a uart driver and this uart is used as
> the console of my board.
> Is it necessary to do some protection in function like that
>
> int uart_write(const char *buf, int len)
> {
> int i;
> for (i = 0; i < len; i++)
> TX_Regsiter = buf[i];
> }
>
> I worried about that if one thread called printf("abc") and another
> called printf("def") then I would got "adbecf".
>
> I noticed that the uart driver of some arm board do nothing to it.
> Does the protection is made by the new-lib?
>
> If so, I should only use standard library to access the console,
> never directly access the uart_write, right?
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
--
Sebastian Huber, Embedded Brains GmbH
Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the users
mailing list