public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: [ECOS] semaphore bug??
@ 2001-08-14 18:55 Geoff Patch
  2001-08-15  0:15 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Geoff Patch @ 2001-08-14 18:55 UTC (permalink / raw)
  To: 'ecos-discuss@sources.redhat.com'

Hi Folks,

> I don't think you can post to a semaphore from an ISR.  You'll
> have to run a DSR and do it there.  There's a table in the eCos
> Reference Manual (Device Driver Interface to the Kernel) that
> shows what functions may be called from an ISR.  About the only
> thing you can do is ack/mask/unmask interrupts and run a DSR.

This is correct, and I recall other postings to the list about this issue. 
 It's obviously a fairly common misconception. I come from a pSOS 
background, where it is possible to post a semaphore in an ISR, and I also 
spent a bad week stumbling over this exact issue .

Could I suggest to the eCos team that an explicit statement of *exactly* 
what can and cannot be done in an ISR be inserted into the "eCos Interrupt 
Model" section of the Reference manual? I'm sure that this would help a lot 
of newbies (like me) retain their sanity. :-)

And while I'm writing, I'd like to say that I think eCos is a great piece 
of gear. Hats off to you guys.


Cheers

Geoff

------------------------------
Geoff Patch
Senior Software Engineer
CEA Technologies
Canberra Australia
02-6213 0141

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [ECOS] semaphore bug??
@ 2001-08-14 12:21 Warren Jasper
  2001-08-14 13:09 ` Grant Edwards
  0 siblings, 1 reply; 5+ messages in thread
From: Warren Jasper @ 2001-08-14 12:21 UTC (permalink / raw)
  To: ecos-discuss

I have written an application that blocks on a semaphore.  When an interrupt is generated, the
semaphore is released, and the program **should** continue.  Here is a snippit:

/* synchronization semaphore */
static  cyg_sem_t dma_store_done_sem;

// I then initialize the semaphore to 0 and register the isr ...

static cyg_uint32 dma_store_done_isr(cyg_vector_t vector, cyg_addrword_t data, cyg_addrword_t *regs)
{
  CYG_WORD32 dspctl;

  //diag_printf("Entered dma_store_done_isr.  vector = %d Releasing semaphore.\n", vector);
  cyg_interrupt_acknowledge(vector);
  /* put the DMA into reset  */
  HAL_READ_UINT32_MCB(DSPCTL, dspctl);
  dspctl |= ResetDMA;
  HAL_WRITE_UINT32_MCB(DSPCTL, dspctl);
  cyg_semaphore_post(&dma_store_done_sem);
  return CYG_ISR_HANDLED;
}

void StoreCoreData( CYG_WORD32 coreAddr, CYG_WORD32 *addr, int nWords )
{
  cyg_count32 value;
  CYG_WORD32 dspctl;
  cyg_mutex_lock(&dma_store_imem_block);

 ... do stuff ...

  if (!cyg_semaphore_timed_wait(&dma_store_done_sem, cyg_current_time() + 10) ) {
    printf("StoreCoreData: semaphore dma_store_done_sem timed out.\n");
    cyg_semaphore_peek(&dma_store_done_sem, &value);
    printf("StoreCoreData: semaphore value = %d\n", value);
  }
  cyg_mutex_unlock(&dma_store_imem_block);
  return;
}

I have checked, and the interrupt is being sent,  and   cyg_semaphore_post() is
being called.  On the second time I try this, I get:

(gdb) c
Continuing.
StoreCoreData: semaphore dma_store_done_sem timed out.
StoreCoreData: semaphore value = 1

How is it possible that the semaphore is blocked when the value is 1?
If I don't put use cyg_semaphore_timed_wait, it blocks forever.  I have checked
and the value of the semaphore just after    cyg_semaphore_post() in the isr
is one.

Any suggestions?

	-- Warren

Warren J. Jasper
wjasper@tx.ncsu.edu

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

end of thread, other threads:[~2001-08-15  0:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-14 18:55 [ECOS] semaphore bug?? Geoff Patch
2001-08-15  0:15 ` Andrew Lunn
2001-08-15  0:24   ` Jonathan Larmour
  -- strict thread matches above, loose matches on Subject: below --
2001-08-14 12:21 Warren Jasper
2001-08-14 13:09 ` Grant Edwards

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).