This is the mail archive of the ecos-discuss@sourceware.org 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]

I2C driver DSR locking


Can someone explain to me how this code fragment from i2c_mcf52xx.c is
supposed to work?  extra->i2c_lock is a mutex to control access to the
extra->i2c_wait condition variable which is used to signal that the
extra->i2c_completed flag should be re-examined.  However
extra->i2c_completed is set true and the condition variable is
signaled by the DSR, which won't be able to run because the DSR lock
has been taken.  Isn't this liable to hang the system?  It looks to me
that locking the DSR is exactly what you don't want to do.

       cyg_drv_mutex_lock(&(extra->i2c_lock));
       cyg_drv_dsr_lock();
       while (! extra->i2c_completed) {
           cyg_drv_cond_wait(&(extra->i2c_wait));
       }
       cyg_drv_dsr_unlock();
       cyg_drv_mutex_unlock(&(extra->i2c_lock));

Thanks,

Rob.

--
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]