This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
RE: drv_lock() cond_wait() drv_unlock() sequence
- To: Grant Edwards <grante at visi dot com>
- Subject: RE: [ECOS] drv_lock() cond_wait() drv_unlock() sequence
- From: Gary Thomas <gthomas at redhat dot com>
- Date: Tue, 04 Apr 2000 17:14:58 -0600 (MDT)
- Cc: ecos-discuss at sourceware dot cygnus dot com
On 04-Apr-00 Grant Edwards wrote:
>
>>From looking at the documentation it would appear that calling
> cyg_drv_dsr_lock() will prevent DSRs from running until
> cyg_drv_dsr_unlock() is called.
>
> But, after looking at the serial driver, this can't be the
> case, since it does a cyg_cond_wait() after locking out DSRs,
> and a DSR is what does a signal() to wake up the waiting task.
>
> It does something like:
>
> cyg_drv_mutex_lock(&mtx)
> cyg_drv_dsr_lock();
> while (1)
> {
> if (done)
> break;
> else
> cyg_drv_cond_wait(&cv);
> }
> cyg_drv_dsr_unlock();
> cyg_drv_mutex_unlock(&mtx);
>
> The call to cyg_drv_cond_wait() must unlock DSRs or the whole
> system would just grind to a halt at that point. When
> cyg_drv_cond_wait() returns, are DSRs again locked out until
> either cyg_drv_cond_wait()or cyg_drv_dsr_unlock() is called?
>
cyg_drv_cond_wait() does an implicit scheduler unlock/relock sequence,
so the operation layout above does work.