public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Re: Possible deadlock in SPI driver for AT91 ARM target
       [not found] <SATURN-V7kBnccYTjr800000364@sagio.com>
@ 2008-03-03 15:46 ` Jonathan Larmour
  2008-03-04  9:01   ` Svend Meyland Nicolaisen
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Larmour @ 2008-03-03 15:46 UTC (permalink / raw)
  To: Svend Meyland Nicolaisen; +Cc: ecos-discuss

Svend Meyland Nicolaisen wrote:
> Hello
> 
> I am looking at the source, spi_at91.c, of the SPI driver for the AT91 ARM
> processor. In the function spi_at91_transfer the following code can be
> found:
> 
> =====>
>         cyg_drv_mutex_lock(&spi_bus->transfer_mx);
>         {
>             spi_bus->transfer_end = false;
>     
>             // Unmask the SPI int
>             cyg_drv_interrupt_unmask(spi_bus->interrupt_number);
>         
>             // Wait for its completition
>             cyg_drv_dsr_lock();
>             {
>                 while (!spi_bus->transfer_end)
>                     cyg_drv_cond_wait(&spi_bus->transfer_cond);
>             }
>             cyg_drv_dsr_unlock();
>         }    
>         cyg_drv_mutex_unlock(&spi_bus->transfer_mx);
> <=====
> 
> The transfer_cond condition is signalled in the DSR routine. Now if the
> DSR's are locked, how can the DSR routine be called to signal the condition?
> Am I missing something?

Yes ;-).

If a thread goes to sleep, the DSRs get unlocked again. When the thread
becomes runnable and is rescheduled, DSRs are relocked. You could consider
this to mean that the scheduler lock is a per-thread property.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [ECOS] Re: Possible deadlock in SPI driver for AT91 ARM target
  2008-03-03 15:46 ` [ECOS] Re: Possible deadlock in SPI driver for AT91 ARM target Jonathan Larmour
@ 2008-03-04  9:01   ` Svend Meyland Nicolaisen
  2008-03-04 17:11     ` Rob Duncan
  0 siblings, 1 reply; 3+ messages in thread
From: Svend Meyland Nicolaisen @ 2008-03-04  9:01 UTC (permalink / raw)
  To: ecos-discuss

 

> -----Original Message-----
> From: ecos-discuss-owner@ecos.sourceware.org 
> [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of 
> Jonathan Larmour
> Sent: 3. marts 2008 16:46
> To: Svend Meyland Nicolaisen
> Cc: ecos-discuss@ecos.sourceware.org
> Subject: [ECOS] Re: Possible deadlock in SPI driver for AT91 
> ARM target
> 
> Svend Meyland Nicolaisen wrote:
> > Hello
> > 
> > I am looking at the source, spi_at91.c, of the SPI driver 
> for the AT91 
> > ARM processor. In the function spi_at91_transfer the following code 
> > can be
> > found:
> > 
> > =====>
> >         cyg_drv_mutex_lock(&spi_bus->transfer_mx);
> >         {
> >             spi_bus->transfer_end = false;
> >     
> >             // Unmask the SPI int
> >             cyg_drv_interrupt_unmask(spi_bus->interrupt_number);
> >         
> >             // Wait for its completition
> >             cyg_drv_dsr_lock();
> >             {
> >                 while (!spi_bus->transfer_end)
> >                     cyg_drv_cond_wait(&spi_bus->transfer_cond);
> >             }
> >             cyg_drv_dsr_unlock();
> >         }    
> >         cyg_drv_mutex_unlock(&spi_bus->transfer_mx);
> > <=====
> > 
> > The transfer_cond condition is signalled in the DSR routine. Now if 
> > the DSR's are locked, how can the DSR routine be called to 
> signal the condition?
> > Am I missing something?
> 
> Yes ;-).
> 
> If a thread goes to sleep, the DSRs get unlocked again. When 
> the thread becomes runnable and is rescheduled, DSRs are 
> relocked. You could consider this to mean that the scheduler 
> lock is a per-thread property.
> 

Ahh, thank you for your answer. Might be a good point to add to the
documentation..... :-)

/Svend


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ECOS] Re: Possible deadlock in SPI driver for AT91 ARM target
  2008-03-04  9:01   ` Svend Meyland Nicolaisen
@ 2008-03-04 17:11     ` Rob Duncan
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Duncan @ 2008-03-04 17:11 UTC (permalink / raw)
  To: Svend Meyland Nicolaisen; +Cc: ecos-discuss

On 3/4/08, Svend Meyland Nicolaisen <ecos@smn.dk> wrote:
>  > If a thread goes to sleep, the DSRs get unlocked again. When
>  > the thread becomes runnable and is rescheduled, DSRs are
>  > relocked. You could consider this to mean that the scheduler
>  > lock is a per-thread property.
>  >
>
>  Ahh, thank you for your answer. Might be a good point to add to the
>  documentation..... :-)

I was confused by this to begin with as well.  It is actually in the
documentation but it's a bit easy to overlook.  Look at the
description of cyg_drv_cond_wait() in the Driver API section of the
Reference Manual.

Rob.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-04 17:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <SATURN-V7kBnccYTjr800000364@sagio.com>
2008-03-03 15:46 ` [ECOS] Re: Possible deadlock in SPI driver for AT91 ARM target Jonathan Larmour
2008-03-04  9:01   ` Svend Meyland Nicolaisen
2008-03-04 17:11     ` Rob Duncan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).