This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: Idle thread trying to sleep
- To: "'Gary Thomas'" <gthomas at redhat dot com>
- Subject: RE: [ECOS] Idle thread trying to sleep
- From: "Trenton D. Adams" <tadams at extremeeng dot com>
- Date: Fri, 6 Jul 2001 09:54:50 -0600
- Cc: "'eCos discussion'" <ecos-discuss at sources dot redhat dot com>
- Organization: Extreme Engineering
> On 06-Jul-2001 Trenton D. Adams wrote:
> > This is what I'm doing. I'm trying to delay 300ms inside
> a function.
> > This function is called in response to an interrupt. Can
> I not delay
> > from within a DSR? How would I delay without using the
> > cyg_thread_delay
> > () function? How am I supposed to know that I'm delaying
> the right
> > amount of time if I can't use cyg_thread_delay ()?
>
> You can't do anything which blocks, including sleeping, in
> a DSR since DSRs are run anonymously.
>
> The way to solve this is to have your DSR control a
> separate thread which can sleep, etc.
>
> Look at the CF ethernet code for an example. There is a
> separate thread which is used to handle card events. When
> a card is inserted, the DSR
> will cause the thread to run. That thread can then do
> things like enable power, etc, which must be sequenced.
Yes, I've seen that code. I suppose it would be best to do it in a
thread. How would I know when the card is ready to use though? Should
I maybe use a mutex or a semaphore in my card driver and PCMCIA driver?
The PCMCIA driver could make the semaphore/mutex global and then my card
driver could attempt access and be blocked until the PCMCIA has
initialized the card. Which should I use, a semaphore or a mutex?
> Note: it might be nice to have this sort of functionality
> as part of the generic CF/PCMCIA support, but at the
> current time it is associated with the specific card driver.
I'm trying to get it working inside my PCMCIA driver so I don't have to
do it in the card driver.
p.s.
I'm kind of doing my PCMCIA driver and CARD driver at the same time.
Thanks Gary and Hugo.