PowerPC exceptions and interrupts

Sebastian Huber Sebastian.Huber at embedded-brains.de
Wed May 21 07:49:18 UTC 2008


Till Straumann wrote:
> [...]
> Another thing that rang my bells was the
> lazy-init of the 'bsp_interrupt_mutex' which
> is not thread safe in its current form. I do
> these e.g., like this:
>
Bad mistake. At first I created the mutex in bsp_interrupt_initialize() 
but I was not sure when it is save to call rtems_semaphore_create().
> if ( ! mutex  ) {
>     tmp_mutex = create_mutex();
>     irq_disable();
>          if ( !mutex ) {
>              mutex = tmp_mutex;
>              irq_enable();
>          } else {
>              /* somebody else won */
>              irq_enable();
>              destroy_mutex(tmp_mutex);
>          }
> }
> take_mutex(mutex);
> [...]
Nice.

-- 
embedded brains GmbH
Sebastian Huber           Obere Lagerstr. 30
D-82178 Puchheim          Germany
Tel. : +49-89-18 90 80 79-6
Fax  : +49-89-18 90 80 79-9
email: 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