This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Blocking design


Hi Folks,

I'd like to have my device driver block while waiting
for the hardware to complete its task.  My basic
design is this:

void invoke_hardware(void)
{
     cyg_drv_mutex_lock(&mutex);
     done = false;
     start_hardware();
     while (!done)
        cyg_drv_cond_wait(&cond);
     cyg_drv_mutex_unlock(&mutex);
}

void hardware_complete_dsr(void)
{
      done = true;
      cyg_drv_cond_signal(&cond);
}

Here's my concern ... The code appears to work fine,
but I think there is a window (albeit small) between
the start_hardware() and the cyg_drv_cond_wait() where
the hardware could complete, trigger the DSR, and
signal the condition variable before the thread has
done the cyg_drv_cond_wait().  If this occurred, the
thread would block indefinitely.

I'd like to find a way to guarantee the thread is
waiting on the condition variable before starting the
hardware.  I can't disable the scheduler, ISRs or DSRs
because the cyg_drv_cond_wait will block and prevent
me from re-enabling them.

Is this a realistic concern?  Any suggestions?
Thanks,
-- Matt

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]