This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: from ISR to thread
- From: Schmidt Henning Larsen <HenningLS at danfoss dot com>
- To: "'ecos-discuss at sources dot redhat dot com'" <ecos-discuss at sources dot redhat dot com>
- Date: Wed, 5 Dec 2001 13:56:38 +0100
- Subject: RE: [ECOS] from ISR to thread
> -----Original Message-----
> From: harri.siirtola@vtt.fi [mailto:harri.siirtola@vtt.fi]
> Sent: 5. december 2001 13:47
> To: Schmidt Henning Larsen; 'ecos-discuss@sources.redhat.com'
> Subject: Re: [ECOS] from ISR to thread
>
>
> At 13:28 5.12.2001 +0100, Schmidt Henning Larsen wrote:
> >Hi
> >...
> >Condition variable: cond
> >Hardware data: hw
> >Ringbuffer: rbuf
> >
> >Threadcode:
> >{
> > while(1)
> > {
> > cyg_drv_cond_wait(cond)
> > data = rbuf.getdata()
> > doSomething(data)
> > }
> >}
> >
> >ISR code:
> >{
> > rbuf.putdata(hw.data)
> > cyg_drv_interrupt_mask() // don't allow interrupt on this device
> > cyg_drv_interrupt_acknowledge()
> > return cyg_isr_call_dsr
> >}
> >
> >DSR code
> >{
> > cyg_drv_cond_signal(cond)
> > cyg_drv_interrupt_unmask() // allow interrupt on this device
> >}
> >
> >
> >This will not work, because if a new interrupt appears while
> the thread is
> >"doingSomething", the thread will not be notified because it
> hasn't returned
> >to the condition variable. When the tread returns to the
> condition variable
> >it has missed the notify, and don't know that it actually
> should run once
> >more. The problem is that we can't call a counting semaphore.
>
> Yes it does, eCos has counting semaphores, too. The type
> cyg_sem_t is such,
> and all you have to do in your thread is something like this:
>
> while (cyg_sem_trywait(sem)) Counter++;
>
> for (i=0; i<Counter; i++)
> dosomething(data);
>
> in your DSR:
>
> cyg_semaphore_post(sem)
>
> every post increments "sem" so you won't miss any. I'm using
> this all the
> time.
>
>
> >I hope someone can tell me if I'm wrong.
> >
> >Henning
>
> Hope I succeeded ;)
>
> Happy coding,
> Harri
>
That would be to easy :-)
You can't use cyg_semaphore_post(sem) in an dsr.
http://sources.redhat.com/ecos/docs-latest/ref/ecos-ref.13.html#pgfId=108034
6
Don't you have any problems. I've been told that it might
corrupt kernel structures.
Henning
Henning