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]

Re: About cyg_drv_dsr_lock and cyg_drv_cond_wait.


chandrag at danlawinc dot com writes:

> Hi,
> 
>   The call cyg_drv_dsr_lock is to prevent DSRs running until the call
> cyg_drv_dsr_unlock is made.
> 
>    One use of cyg_drv_cond_wait is to wait (block) for input from a
> device.
>    To wake up a thread that is waiting on a condition variable a DSR can
> 
> call cyg_drv_cond_signal.
> 
>    My question is -
> 
>     A call to cyg_drv_cond_wait in most of the devices (e.g..
> serial_read of
> serial.c) is between the calls cyg_drv_dsr_lock and cyg_drv_dsr_unlock.
> This happens when a thread is waiting for input from a device, waiting
> for the
> corresponding DSR to run.  But DSRs can not run because of dsr_lock.
> How is this happening?
> 
>    My analysis may be missing something, what is that?
> 

The DSR lock is essentially a per-thread value. When in
cyg_drv_cond_wait() the context is switched to another thread then
that thread's DSR lock value is used. Eventually we will get to a
thread that has a zero DSR lock, for example the idle thread, at which
point the DSR will run. When the first thread is resumed, its lock
value is reinstalled, and it continues its critical region.

-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


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


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