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] |
On Mon, 2004-02-09 at 15:37, Matt Jerdonek wrote:
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(). [snip]
Yes, but your concerns are a bit unfounded. Use "cyg_drv_dsr_lock()" and "cyg_drv_dsr_unlock()" [which are just calls to lock/unlock the scheduler, but it's best to follow the same API]. When your thread blocks by calling 'cyg_drv_cond_wait()', the scheduler will be unlocked as necessary.
Jifl -- eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts >>>>> Visit us in booth 2527 at the Embedded Systems Conference 2004 <<<<< March 30 - April 1, San Francisco http://www.esconline.com/electronicaUSA/ --["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine
-- 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] |